feat(otel): Enable improved OTel trace compatibility via opt-in configuration#8894
Conversation
… to update the DD span's resource name. Previously, this updated the operation name which was a bug
…ects the updated API implementation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 77f2fd7 | Docs | Datadog PR Page | Give us feedback! |
Overall package sizeSelf size: 6.25 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.2 | 85.93 kB | 825.11 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0184055bb1
ℹ️ 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".
…since it's only exercised by test code
…re updating the otel name
…lemetry semantic conventions for tracing. Concretely, this results in the following changes: - When emitting OTLP traces we omit Datadog-only attributes 'service.name', 'operation.name', 'span.type', and 'resource.name' - The OTel Tracing API is updated to _not_ remap the attribute 'http.response.status_code' - The OTel Tracing recordException API is updated to not write error tags on the span. The exception is entirely captured in a span event, per the OpenTelemetry specification - The OTel Tracing setStatus API is updated to rewrite the span error message on the last update of the span status - All behavior is enabled with the environment variable DD_TRACE_OTEL_COMPATIBILITY_ENABLED
…DD_TRACE_OTEL_SEMANTICS_ENABLED
…e via environment variables
0184055 to
00fabbd
Compare
BenchmarksBenchmark execution time: 2026-06-16 16:59:17 Comparing candidate commit 77f2fd7 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1936 metrics, 14 unstable metrics.
|
marcotc
left a comment
There was a problem hiding this comment.
👍 from the OTel payload point of view.
…ABLED configuration
…d as a bool, so fix callsites
…csEnabled no longer has a default value - it doesn't need it
…the Datadog "error.message" attribute
…parameter is no longer optional
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM, while a few calls could likely receive the argument in all situations.
…guration (#8894) * Breaking change: Updates the `updateName` function in the OTel Bridge to update the DD span's resource name. Previously, this updated the operation name which was a bug * Update OpenTelemetry express test with an updated assertion that reflects the updated API implementation * Fix the accessors of the OTel Span Name to set/retrieve the resource name * Address PR Feedback: use a private property to store the OTel name * Address PR feedback: Remove 'setOtelOperationName' from span-helpers since it's only exercised by test code * Address PR feedback: In 'updateName', check if the span is ended before updating the otel name * Add a new opt-in configuration to enable stricter adherence to OpenTelemetry semantic conventions for tracing. Concretely, this results in the following changes: - When emitting OTLP traces we omit Datadog-only attributes 'service.name', 'operation.name', 'span.type', and 'resource.name' - The OTel Tracing API is updated to _not_ remap the attribute 'http.response.status_code' - The OTel Tracing recordException API is updated to not write error tags on the span. The exception is entirely captured in a span event, per the OpenTelemetry specification - The OTel Tracing setStatus API is updated to rewrite the span error message on the last update of the span status - All behavior is enabled with the environment variable DD_TRACE_OTEL_COMPATIBILITY_ENABLED * Rename the configuration from DD_TRACE_OTEL_COMPATIBILITY_ENABLED to DD_TRACE_OTEL_SEMANTICS_ENABLED * Make the new setting DD_TRACE_OTEL_SEMANTICS_ENABLED only configurable via environment variables * Remove unneeded in-code config * Place the changes to updateName behind the DD_TRACE_OTEL_SEMANTICS_ENABLED configuration * Address PR feedback: DD_TRACE_OTEL_SEMANTICS_ENABLED is always defined as a bool, so fix callsites * Update setOtelAttribute and setOtelAttributes so the otelTraceSemanticsEnabled no longer has a default value - it doesn't need it * Address PR feedback: Update the OTLP transformer so it does not emit the Datadog "error.message" attribute * Update span-helpers and its tests so the 'otelTraceSemanticsEnabled' parameter is no longer optional * Update packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js
…guration (#8894) * Breaking change: Updates the `updateName` function in the OTel Bridge to update the DD span's resource name. Previously, this updated the operation name which was a bug * Update OpenTelemetry express test with an updated assertion that reflects the updated API implementation * Fix the accessors of the OTel Span Name to set/retrieve the resource name * Address PR Feedback: use a private property to store the OTel name * Address PR feedback: Remove 'setOtelOperationName' from span-helpers since it's only exercised by test code * Address PR feedback: In 'updateName', check if the span is ended before updating the otel name * Add a new opt-in configuration to enable stricter adherence to OpenTelemetry semantic conventions for tracing. Concretely, this results in the following changes: - When emitting OTLP traces we omit Datadog-only attributes 'service.name', 'operation.name', 'span.type', and 'resource.name' - The OTel Tracing API is updated to _not_ remap the attribute 'http.response.status_code' - The OTel Tracing recordException API is updated to not write error tags on the span. The exception is entirely captured in a span event, per the OpenTelemetry specification - The OTel Tracing setStatus API is updated to rewrite the span error message on the last update of the span status - All behavior is enabled with the environment variable DD_TRACE_OTEL_COMPATIBILITY_ENABLED * Rename the configuration from DD_TRACE_OTEL_COMPATIBILITY_ENABLED to DD_TRACE_OTEL_SEMANTICS_ENABLED * Make the new setting DD_TRACE_OTEL_SEMANTICS_ENABLED only configurable via environment variables * Remove unneeded in-code config * Place the changes to updateName behind the DD_TRACE_OTEL_SEMANTICS_ENABLED configuration * Address PR feedback: DD_TRACE_OTEL_SEMANTICS_ENABLED is always defined as a bool, so fix callsites * Update setOtelAttribute and setOtelAttributes so the otelTraceSemanticsEnabled no longer has a default value - it doesn't need it * Address PR feedback: Update the OTLP transformer so it does not emit the Datadog "error.message" attribute * Update span-helpers and its tests so the 'otelTraceSemanticsEnabled' parameter is no longer optional * Update packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js
What does this PR do?
This PR adds a configuration to process spans as closely as possible to the OTel SDK. The result is that using OpenTelemetry Tracing instrumentations allows DD SDKs to produce OTLP spans with nearly identical span fields.
When enabled, this updates the dd-trace-js behavior in the following ways:
OtelSpan.updateNameno longer updates the operation name. Instead, it now updates the resource name, which is the expected OpenTelemetry behavior.OtelSpan.setAttributeno longer remaps the taghttp.response.status_codeso it will maintain its intended key and value typeOtelSpan.recordExceptionno longer sets span attributeserror.message,error.type, orerror.stack. These exist on theexceptionspan event and will be recognized by Error TrackingOtelSpan.setStatusnow overwrites the span's status message with the latest status. This means a previous ERROR status with a message that is then upgraded to OK will have the status message cleared.service.nameoperation.nameresource.namespan.typespan.kinderror.messageMotivation
We want to enable OpenTelemetry SDK users to migrate to the Datadog SDK in their language ecosystem, so this change allows them to export OTLP spans from the Datadog SDK without the shape of their data changing. This is most notable when using the OpenTelemetry Tracing API and OpenTelemetry Instrumentation Libraries to generate traces -- with this new semantic mode, the OTLP span should reach the backend without its semantics changing.
Additional Notes
N/A