@@ -25,6 +25,7 @@ import (
2525 "github.com/elastic/apm-data/model/modelpb"
2626 "go.opentelemetry.io/collector/pdata/pcommon"
2727 semconv "go.opentelemetry.io/collector/semconv/v1.27.0"
28+ semconv22 "go.opentelemetry.io/collector/semconv/v1.22.0"
2829)
2930
3031// Translates resource attributes from the Elastic APM model to SemConv resource attributes
@@ -36,7 +37,28 @@ func TranslateToOtelResourceAttributes(event *modelpb.APMEvent, attributes pcomm
3637 }
3738 attributes .PutStr (semconv .AttributeTelemetrySDKName , "ElasticAPM" )
3839 if event .Service .Environment != "" {
39- attributes .PutStr (semconv .AttributeDeploymentEnvironmentName , event .Service .Environment )
40+ // elasticsearchexporter currently uses v1.22.0 of the OTel SemConv, so we need to use the v1.22.0 attribute
41+ attributes .PutStr (semconv22 .AttributeDeploymentEnvironment , event .Service .Environment )
42+ }
43+ if event .Service .Node != nil && event .Service .Node .Name != "" {
44+ attributes .PutStr (semconv .AttributeServiceInstanceID , event .Service .Node .Name )
45+ }
46+ if event .Host != nil {
47+ if event .Host .Name != "" {
48+ attributes .PutStr (semconv .AttributeHostName , event .Host .Name )
49+ }
50+ if event .Host .Id != "" {
51+ attributes .PutStr (semconv .AttributeHostID , event .Host .Id )
52+ }
53+ if event .Host .Architecture != "" {
54+ attributes .PutStr (semconv .AttributeHostArch , event .Host .Architecture )
55+ }
56+ if event .Host .Os .Name != "" {
57+ attributes .PutStr (semconv .AttributeOSName , event .Host .Os .Name )
58+ if event .Host .Os .Version != "" {
59+ attributes .PutStr (semconv .AttributeOSVersion , event .Host .Os .Version )
60+ }
61+ }
4062 }
4163}
4264
0 commit comments