Skip to content

Commit

Permalink
Map system.filesystem.mount_point from otel-lib to ES (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahsivjar authored Jul 5, 2024
1 parent 74da991 commit 5179047
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 34 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/elastic/apm-data
go 1.21.1

require (
github.com/elastic/opentelemetry-lib v0.6.1
github.com/elastic/opentelemetry-lib v0.7.0
github.com/google/go-cmp v0.6.0
github.com/jaegertracing/jaeger v1.58.1
github.com/json-iterator/go v1.1.12
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
github.com/elastic/opentelemetry-lib v0.6.1 h1:Ayx82UH+oXF2222wmKTcRcq0todI6btpd8KF1tz1ZQ8=
github.com/elastic/opentelemetry-lib v0.6.1/go.mod h1:/kKvHbJLVo/NcKMPHI8/RZKL64fushmnRUzn+arQpjg=
github.com/elastic/opentelemetry-lib v0.7.0 h1:sarbwqZJ9sx+B1zUl6qmf93/j7ggDAidc5CYKsIsQQk=
github.com/elastic/opentelemetry-lib v0.7.0/go.mod h1:/kKvHbJLVo/NcKMPHI8/RZKL64fushmnRUzn+arQpjg=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down
4 changes: 3 additions & 1 deletion input/elasticapm/internal/modeldecoder/v2/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ func isUnmappedMetadataField(key string) bool {
"system.process",
"system.process.state",
"system.process.cmdline",
"system.process.cpu.start_time":
"system.process.cpu.start_time",
"system.filesystem",
"system.filesystem.mount_point":
return true
}
return false
Expand Down
8 changes: 8 additions & 0 deletions input/otlp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ func (c *Consumer) handleScopeMetrics(
event.System.Process = modelpb.SystemProcessFromVTPool()
}
event.System.Process.State = v.Str()
case "system.filesystem.mount_point":
if event.System == nil {
event.System = modelpb.SystemFromVTPool()
}
if event.System.Filesystem == nil {
event.System.Filesystem = modelpb.SystemFilesystemFromVTPool()
}
event.System.Filesystem.MountPoint = truncate(v.Str())
case "event.dataset":
if event.Event == nil {
event.Event = modelpb.EventFromVTPool()
Expand Down
6 changes: 6 additions & 0 deletions input/otlp/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ func TestConsumeMetricsWithOTelRemapper(t *testing.T) {
},
},
},
Event: &modelpb.Event{
Dataset: "system.load",
},
Labels: map[string]*modelpb.LabelValue{
"otel_remapped": &modelpb.LabelValue{Value: "true"},
},
Expand Down Expand Up @@ -1058,6 +1061,9 @@ func TestConsumeMetricsWithOTelRemapper(t *testing.T) {
Labels: map[string]*modelpb.LabelValue{
"otel_remapped": &modelpb.LabelValue{Value: "true"},
},
Event: &modelpb.Event{
Dataset: "system.process",
},
},
},
},
Expand Down
31 changes: 30 additions & 1 deletion model/modeljson/internal/marshal_fastjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion model/modeljson/internal/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
package modeljson

type System struct {
Process SystemProcess `json:"process,omitempty"`
Process SystemProcess `json:"process,omitempty"`
Filesystem SystemFilesystem `json:"filesystem,omitempty"`
}

type SystemProcess struct {
Expand All @@ -38,3 +39,11 @@ type SystemProcessCPU struct {
func (p *SystemProcessCPU) isZero() bool {
return p == nil || p.StartTime == ""
}

type SystemFilesystem struct {
MountPoint string `json:"mount_point,omitempty"`
}

func (f *SystemFilesystem) isZero() bool {
return f == nil || f.MountPoint == ""
}
5 changes: 5 additions & 0 deletions model/modeljson/system.pb.json.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ func SystemModelJSON(s *modelpb.System, out *modeljson.System) {
}
}
}
if s.Filesystem != nil {
out.Filesystem = modeljson.SystemFilesystem{
MountPoint: s.Filesystem.MountPoint,
}
}
}
6 changes: 6 additions & 0 deletions model/modeljson/system.pb.json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func TestSystemToModelJSON(t *testing.T) {
StartTime: ts.Format(time.RFC3339),
},
},
Filesystem: &modelpb.SystemFilesystem{
MountPoint: "fsmountpoint",
},
},
expected: &modeljson.System{
Process: modeljson.SystemProcess{
Expand All @@ -55,6 +58,9 @@ func TestSystemToModelJSON(t *testing.T) {
StartTime: ts.Format(time.RFC3339),
},
},
Filesystem: modeljson.SystemFilesystem{
MountPoint: "fsmountpoint",
},
},
},
}
Expand Down
133 changes: 105 additions & 28 deletions model/modelpb/system.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5179047

Please sign in to comment.