Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle otlp semconv deployment.environment.name alongside deprecated deployment.environment #384

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[to reviewer] No precedence between deprecated and new field, so the one appears later in the resource attributes wins.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a question on semconv.AttributeDeploymentEnvironment: is it possible for it to change in future releases of semconv? Or being deprecated applies some special handling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@lahsivjar lahsivjar Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, we can also import semconv by versions to make things clear on what is latest and what is old - all semconvs are provided by the same module.

Something like semconv18. AttributeDeploymentEnvironment vs semconv27.AttributeDeploymentEnvironmentName - just an idea I have been playing around with for some other projects.

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
Loading