From 8e3a1a7610074fb5dfa7f794b1e1b3e3dca5857e Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Mon, 14 Oct 2024 14:43:04 +0100 Subject: [PATCH] Handle otlp semconv deployment.environment.name alongside deprecated deployment.environment (#384) --- input/otlp/metadata.go | 3 ++- input/otlp/metadata_test.go | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/input/otlp/metadata.go b/input/otlp/metadata.go index 3d528a91..2a1e854c 100644 --- a/input/otlp/metadata.go +++ b/input/otlp/metadata.go @@ -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{} } diff --git a/input/otlp/metadata_test.go b/input/otlp/metadata_test.go index df0a914e..db5a48cf 100644 --- a/input/otlp/metadata_test.go +++ b/input/otlp/metadata_test.go @@ -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", @@ -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",