feat(tracer): add DD_TRACE_OTEL_SEMANTICS_ENABLED for OTLP export#4889
feat(tracer): add DD_TRACE_OTEL_SEMANTICS_ENABLED for OTLP export#4889link04 wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-06-16 15:26:51 Comparing candidate commit 6dda781 in PR branch Found 3 performance improvements and 0 performance regressions! Performance is the same for 294 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.
|
4194e3a to
b23cf4e
Compare
Opt-in mode that aligns OTLP-exported spans with the pure OpenTelemetry SDK by suppressing Datadog-specific attributes and stopping DD-convention remaps. Mirrors dd-trace-py #18495 and libdatadog #2091. When DD_TRACE_OTEL_SEMANTICS_ENABLED=true: - omit operation.name, resource.name, span.type (DD-only span attributes) - omit error.message/type/stack/handling_stack from the span (they live on the exception span event for Error Tracking) - omit span.kind (already carried by the first-class OTLP SpanKind field) - keep http.response.status_code under its OTel key instead of remapping to the legacy http.status_code string tag - the OTel bridge no longer interprets Datadog reserved tags (operation.name, analytics.event, http.response.status_code) in SetAttributes - SetName updates the Datadog resource (the OTLP span name) instead of the DD-only operation name; gated here because changing it by default shifts RED metrics Registers the key in supported_configurations so env.Get resolves it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
b23cf4e to
6dda781
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6dda781634
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| func toReservedAttributes(k string, v attribute.Value, otelSemantics bool) (string, any) { | ||
| if otelSemantics { | ||
| // Under OTel semantics, set every attribute as-is (no DD reserved-tag remapping). | ||
| return k, v.AsInterface() |
There was a problem hiding this comment.
Preserve OTel attrs instead of DD pseudo-tags
With DD_TRACE_OTEL_SEMANTICS_ENABLED=true, this path stores keys such as resource.name, service.name, span.type, and operation.name unchanged in s.attributes, but End still forwards every entry through s.DD.SetTag, where those exact names are Datadog pseudo-tags rather than regular attributes. For example, SetAttributes(attribute.String("resource.name", "x")) changes the exported OTLP span name/resource and emits no resource.name attribute, so the new flag does not actually preserve OTel attributes as-is for these inputs.
Useful? React with 👍 / 👎.
What does this PR do?
Adds an opt-in
DD_TRACE_OTEL_SEMANTICS_ENABLEDthat aligns OTLP-exported spans (and the OTel bridge) with the pure OpenTelemetry SDK by suppressing Datadog-specific attributes and stopping DD-convention remaps. Mirrors dd-trace-py #18495 and libdatadog #2091.Behavior when
DD_TRACE_OTEL_SEMANTICS_ENABLED=trueoperation.name,resource.name,span.type(DD-only span attributes)error.message/type/stack/handling_stackfrom the span (they live on the exception span event for Error Tracking)span.kind(already carried by the first-class OTLPSpanKindfield)http.response.status_codeunder its OTel key instead of remapping to the legacyhttp.status_codestring tagoperation.name,analytics.event,http.response.status_code) inSetAttributes— they pass through as providedSetNameupdates the Datadog resource (which the OTLP exporter emits as the span name) instead of the DD-only operation nameDefault (flag off) behavior is unchanged.
Why
SetNameis gated here (moved from #4887)Changing
SetNameto update the resource is the correct OTel-aligned behavior, but doing it unconditionally is a breaking change: it shifts both the operation name and resource name, which changes users' RED metrics. Per team discussion (matching the dd-trace-js decision), this belongs behind the semantics flag rather than as a default change in a minor release. This supersedes #4887.Performance
The flag is read once per export batch in
otlpTraceWriter.add()and resolved once at provider creation for the bridge (cached on theoteltracer), then threaded as a parameter / read as a field — no per-span/per-attribute global config lookup.Testing
TestConvertSpanAttributesOtelSemantics,TestRemapStatusCodeOtelSemantics,TestToReservedAttributesOtelSemantics, andTestSpanSetNameUpdatesResourceOtelSemantics(flag on) plus the existingTestSpanSetName(flag off, legacy operation-name behavior). Fullddtrace/tracer,ddtrace/opentelemetry, andinternal/configsuites pass.🤖 Generated with Claude Code