fix(opentelemetry): sync resource name with OTel span name on SetName#4887
fix(opentelemetry): sync resource name with OTel span name on SetName#4887link04 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4e2bd38 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-06-12 21:20:19 Comparing candidate commit 4e2bd38 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 294 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.
|
|
For maintainers, this same type of issue was discovered in dd-trace-js where the |
| s.attributes[ext.SpanName] = strings.ToLower(name) | ||
| // Keep the resource in sync with the renamed span: Start seeds the resource from the | ||
| // initial name, and the OTLP exporter emits the resource as the span's name field. | ||
| s.attributes[ext.ResourceName] = name |
There was a problem hiding this comment.
Yep this change looks correct. In the linked dd-trace-js PR, we replaced the previous "set the operation name" instruction with this new "set the resource name" instruction. Can we do the same here in dd-trace-go?
zacharycmontoya
left a comment
There was a problem hiding this comment.
LGTM. Let's see if we can replace the previous "operation name" update entirely since operation name is a DD-only concept
f892dc2 to
58392f8
Compare
…name on SetName
tracer.Start seeds the DD resource from the initial OTel span name, but SetName
only updated the operation name — so the resource (and therefore the span name
exported over OTLP) kept the stale value. Instrumentations such as otelhttp
create the span before routing ("GET") and call SetName with the low-cardinality
route afterwards ("GET /users/{id}"); the exported OTLP span name must follow.
SetName now updates the resource name only. The operation name is a Datadog-only
concept derived from the span's semantics, so it is no longer set from the OTel
span name (matching the dd-trace-js change).
Fixes the span name diverging from the pure OpenTelemetry SDK over OTLP.
Independent of DD_TRACE_OTEL_SEMANTICS_ENABLED.
APMAPI-2016
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58392f8 to
4e2bd38
Compare
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenTelemetry bridge span renaming behavior so that calling Span.SetName(...) updates the underlying Datadog resource name (which is what ultimately maps to the OTLP-exported span name), rather than changing the Datadog operation name.
Changes:
- Update
(*span).SetNameto writeext.ResourceName(resource) instead ofext.SpanName(operation). - Adjust existing
TestSpanSetNameexpectations to validate resource rename behavior and unchanged DD-computed operation name. - Add a new regression test covering a common HTTP route-renaming scenario (e.g.,
"GET"→"GET /users/{id}").
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ddtrace/opentelemetry/span.go | Make SetName update Datadog resource name to keep OTLP span name in sync with OTel renames. |
| ddtrace/opentelemetry/span_test.go | Update assertions for the new mapping and add coverage for post-start span renames. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Superseded by #4889. Per the team discussion (and matching the dd-trace-js decision), the |
What does this PR do?
Makes the OTel bridge's
SetNamealso update the Datadog resource name (not just the operation name), so the span name exported over OTLP follows a laterSetNamecall.Motivation
tracer.Startseeds the DD resource from the initial OTel span name, butSetNameonly updated the operation name — the resource (and thus the OTLP-exported span name) kept the stale value. Instrumentations likeotelhttpcreate the span before routing ("GET") and callSetNamewith the low-cardinality route afterwards ("GET /users/{id}"); the exported OTLP span name must follow to match the pure OpenTelemetry SDK.Independent of
DD_TRACE_OTEL_SEMANTICS_ENABLED.Testing
Adds
TestSpanSetNameUpdatesResource. Fullddtrace/opentelemetrysuite passes.APMAPI-2016
🤖 Generated with Claude Code