Skip to content

Commit

Permalink
Handle otlp semconv deployment.environment.name alongside deprecated …
Browse files Browse the repository at this point in the history
…deployment.environment (#384)
  • Loading branch information
carsonip authored Oct 14, 2024
1 parent ed18118 commit 8e3a1a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion input/otlp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func translateResourceMetadata(resource pcommon.Resource, out *modelpb.APMEvent)
out.Service.Node.Name = truncate(v.Str())

// deployment.*
case semconv.AttributeDeploymentEnvironment:
// deployment.environment is deprecated, use deployment.environment.name instead
case semconv.AttributeDeploymentEnvironment, "deployment.environment.name":
if out.Service == nil {
out.Service = &modelpb.Service{}
}
Expand Down
20 changes: 19 additions & 1 deletion input/otlp/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestResourceConventions(t *testing.T) {
attrs: nil,
expected: &modelpb.APMEvent{Agent: &defaultAgent, Service: &defaultService},
},
"service": {
"service with deprecated deployment.environment": {
attrs: map[string]interface{}{
"service.name": "service_name",
"service.version": "service_version",
Expand All @@ -61,6 +61,24 @@ func TestResourceConventions(t *testing.T) {
},
},
},
"service": {
attrs: map[string]interface{}{
"service.name": "service_name",
"service.version": "service_version",
"service.instance.id": "service_node_name",
"deployment.environment.name": "service_environment",
},
expected: &modelpb.APMEvent{
Agent: &modelpb.Agent{Name: "otlp", Version: "unknown"},
Service: &modelpb.Service{
Name: "service_name",
Version: "service_version",
Environment: "service_environment",
Node: &modelpb.ServiceNode{Name: "service_node_name"},
Language: &modelpb.Language{Name: "unknown"},
},
},
},
"agent": {
attrs: map[string]interface{}{
"telemetry.sdk.name": "sdk_name",
Expand Down

0 comments on commit 8e3a1a7

Please sign in to comment.