Skip to content

Commit 2842f86

Browse files
committed
model: add system.network.{cpus,memory,network}
1 parent 0d5f795 commit 2842f86

File tree

5 files changed

+142
-3
lines changed

5 files changed

+142
-3
lines changed

docs/spec/v2/metadata.json

+53
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@
394394
}
395395
}
396396
},
397+
"cpus": {
398+
"description": "CPUCores holds the number of CPU cores of the system on which the monitored service is running.",
399+
"type": [
400+
"null",
401+
"integer"
402+
],
403+
"minimum": 1
404+
},
397405
"detected_hostname": {
398406
"description": "DetectedHostname is the hostname detected by the APM agent. It usually contains what the hostname command returns on the host machine. It will be used as the event's hostname if ConfiguredHostname is not present.",
399407
"type": [
@@ -469,6 +477,51 @@
469477
}
470478
}
471479
},
480+
"memory": {
481+
"description": "Memory holds the memory of the system on which the monitored service is running, in bytes.",
482+
"type": [
483+
"null",
484+
"integer"
485+
],
486+
"minimum": 1
487+
},
488+
"network": {
489+
"description": "Network holds information about the network that the system is connected to. This is only relevant for browsers and mobile devices. See https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation for more details on how these fields should be set and interpreted for browsers.",
490+
"type": [
491+
"null",
492+
"object"
493+
],
494+
"properties": {
495+
"downlink": {
496+
"description": "Downlink holds the effective bandwidth estimate in megabits per second.",
497+
"type": [
498+
"null",
499+
"integer"
500+
]
501+
},
502+
"effectivetype": {
503+
"description": "EffectiveType describes the effective network type as one of a discrete set of network types, e.g. 'slow-2g', '2g', '3g', or '4g'.",
504+
"type": [
505+
"null",
506+
"string"
507+
]
508+
},
509+
"rtt": {
510+
"description": "RTT holds the estimated effective round-trip time of the current connection, in milliseconds.",
511+
"type": [
512+
"null",
513+
"integer"
514+
]
515+
},
516+
"savedata": {
517+
"description": "SaveData reports whether or not reduced data usage has been enabled on the client device.",
518+
"type": [
519+
"null",
520+
"boolean"
521+
]
522+
}
523+
}
524+
},
472525
"platform": {
473526
"description": "Platform name of the system platform the monitored service is running on.",
474527
"type": [

model/modeldecoder/v2/decoder.go

+6
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,12 @@ func mapToMetadataModel(from *metadata, out *model.Metadata) {
512512
if from.System.Platform.IsSet() {
513513
out.System.Platform = from.System.Platform.Val
514514
}
515+
if from.System.Memory.IsSet() {
516+
out.System.Memory = from.System.Memory.Val
517+
}
518+
if from.System.CPUCores.IsSet() {
519+
out.System.CPUCores = from.System.CPUCores.Val
520+
}
515521

516522
// User
517523
if from.User.ID.IsSet() {

model/modeldecoder/v2/model.go

+29
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,18 @@ type metadataSystem struct {
502502
Kubernetes metadataSystemKubernetes `json:"kubernetes"`
503503
// Platform name of the system platform the monitored service is running on.
504504
Platform nullable.String `json:"platform" validate:"maxLength=1024"`
505+
// Memory holds the memory of the system on which the monitored service is
506+
// running, in bytes.
507+
Memory nullable.Int `json:"memory" validate:"min=1"`
508+
// CPUCores holds the number of CPU cores of the system on which the monitored
509+
// service is running.
510+
CPUCores nullable.Int `json:"cpus" validate:"min=1"`
511+
// Network holds information about the network that the system is connected to.
512+
// This is only relevant for browsers and mobile devices.
513+
//
514+
// See https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation for
515+
// more details on how these fields should be set and interpreted for browsers.
516+
Network metadataSystemNetwork `json:"network"`
505517
}
506518

507519
type metadataSystemContainer struct {
@@ -530,6 +542,23 @@ type metadataSystemKubernetesPod struct {
530542
UID nullable.String `json:"uid" validate:"maxLength=1024"`
531543
}
532544

545+
type metadataSystemNetwork struct {
546+
// Downlink holds the effective bandwidth estimate in megabits per second.
547+
Downlink nullable.Int
548+
549+
// EffectiveType describes the effective network type as one of a
550+
// discrete set of network types, e.g. 'slow-2g', '2g', '3g', or '4g'.
551+
EffectiveType nullable.String
552+
553+
// RTT holds the estimated effective round-trip time of the current
554+
// connection, in milliseconds.
555+
RTT nullable.Int
556+
557+
// SaveData reports whether or not reduced data usage has been enabled
558+
// on the client device.
559+
SaveData nullable.Bool
560+
}
561+
533562
type metricset struct {
534563
// Timestamp holds the recorded time of the event, UTC based and formatted
535564
// as microseconds since Unix epoch

model/modeldecoder/v2/model_generated.go

+31-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/system.go

+23-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,24 @@ type System struct {
2929
Architecture string
3030
Platform string
3131
IP net.IP
32+
Container Container
33+
Kubernetes Kubernetes
3234

33-
Container Container
34-
Kubernetes Kubernetes
35+
// Memory holds the total system memory, in bytes.
36+
//
37+
// This may be recorded for short-lived operations,
38+
// such as browser requests or serverless function
39+
// invocations, where the amount of available memory
40+
// may be pertinent to request performance.
41+
Memory int
42+
43+
// CPUCores holds the total number of CPU cores.
44+
//
45+
// This may be recorded for short-lived operations,
46+
// such as browser requests or serverless function
47+
// invocations, where the number of CPUs may be
48+
// pertinent to request performance.
49+
CPUCores int
3550
}
3651

3752
func (s *System) name() string {
@@ -76,6 +91,12 @@ func (s *System) fields() common.MapStr {
7691
if s.IP != nil {
7792
system.set("ip", s.IP.String())
7893
}
94+
if s.Memory > 0 {
95+
system.set("memory.total", s.Memory)
96+
}
97+
if s.CPUCores > 0 {
98+
system.set("cpu.cores", s.CPUCores)
99+
}
79100
return common.MapStr(system)
80101
}
81102

0 commit comments

Comments
 (0)