feat(config): support OTEL_PROPAGATORS as propagation style fallback#271
Conversation
Adds 6 new unit tests covering: - DD wins precedence over OTEL_PROPAGATORS - Unsupported propagator names are filtered out - Baggage and None styles are supported - Extract/inject inherit global style from OTEL_PROPAGATORS - Mixed DD_TRACE_PROPAGATION_STYLE_EXTRACT + OTEL_PROPAGATORS precedence - Default style when no env vars set Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CONTRIBUTING.md requires test-only imports at the top of the `mod tests` block rather than inside individual test functions. Moves the get_extractors/get_injectors import out of the two test bodies. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 9667a09 | Docs | Datadog PR Page | Give us feedback! |
The Feature Parity Dashboard registers OTEL_PROPAGATORS (version A) with an empty-string default, not null. The config-inversion local validation job (validate_supported_configurations_v2_local_file) rejected the null default as a registry mismatch. Align the entry with the registry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drops the bespoke update_parsed_with_transform_with_fallback helper and wires OTEL_PROPAGATORS onto trace_propagation_style via the existing update_non_empty_string_with_fallback (the same helper used for the OTEL_SERVICE_NAME alias), splitting the comma-separated value in the transform closure. This makes the two OTEL_* aliases consistent: an empty DD_TRACE_PROPAGATION_STYLE is now treated as unset (falls back to OTEL_PROPAGATORS, then the default) rather than yielding an empty style list. Updates the two propagation tests that asserted the old empty-string-as-empty-list behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8cb540f83a
ℹ️ 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".
| trace_propagation_style: cisu.update_non_empty_string_with_fallback( | ||
| default.trace_propagation_style, | ||
| SupportedConfigurations::OTEL_PROPAGATORS, |
There was a problem hiding this comment.
Honor DD-specific propagation style precedence
With DD_TRACE_PROPAGATION_STYLE_EXTRACT=datadog and OTEL_PROPAGATORS=tracecontext, this fallback still sets the global style from OTEL, so get_injectors (which falls back to the global style when _INJECT is absent) injects only tracecontext instead of the default global styles. Datadog documents OTEL_PROPAGATORS as lowest precedence and ignored when another Datadog trace context propagation variable is set (https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation/), so the fallback should also be skipped when the extract/inject style keys are present.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Checked the other tracers on this. For this exact case (DD_TRACE_PROPAGATION_STYLE_EXTRACT set, global + _INJECT unset, OTEL_PROPAGATORS set), inject also inherits OTEL_PROPAGATORS in dd-trace-py, dd-trace-go, dd-trace-java, and dd-trace-js — only php/rb fall back to the default. Here OTEL_PROPAGATORS is a fallback for the global DD_TRACE_PROPAGATION_STYLE, and extract/inject inherit the global when their own key isn't set (existing get_extractors/get_injectors behavior), so this matches the reference impls. Agreed the php/rb split isn't ideal and probably deserves a cross-tracer alignment, but that's out of scope for this PR — keeping as-is here.
iunanua
left a comment
There was a problem hiding this comment.
Is possible to enable the corresponding system tests? Although I've taken a quick look, it seems to me that to enable them, we need to support other otel env vars.
| // Unknown propagator names (e.g. "jaeger") are dropped; supported ones are kept. | ||
| let mut sources = CompositeSource::new(); | ||
| sources.add_source(HashMapSource::from_iter( | ||
| [("OTEL_PROPAGATORS", "jaeger,tracecontext")], |
There was a problem hiding this comment.
when DD_TRACE_PROPAGATION_STYLE is unset and OTEL_PROPAGATORS=unsupported_style, I think config.trace_propagation_style() returns an empty array. Should it return the default values instead?
There was a problem hiding this comment.
yep good point, done in 9667a09 - all-unsupported OTEL_PROPAGATORS now falls back to the default instead of an empty list.
…all-unsupported Addresses review feedback: - Reuse the DdTags wrapper in the fallback transform instead of an inline comma-split, matching the extract/inject closures. - When the global propagation style parses to no recognized styles (e.g. OTEL_PROPAGATORS=jaeger with only unsupported values), fall back to the default set rather than silently disabling propagation. Reads the default from the existing ConfigItem so the list isn't duplicated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@iunanua Dug into this - it's mostly harness gaps, not missing OTEL vars. The |
…271) # What does this PR do? Adds support for the OpenTelemetry `OTEL_PROPAGATORS` env var as a fallback for `DD_TRACE_PROPAGATION_STYLE`. When `DD_TRACE_PROPAGATION_STYLE` is unset, dd-trace-rs reads `OTEL_PROPAGATORS` and applies it to the global propagation style, matching the other Datadog tracers (Python, Go, Java, Node.js, .NET, Ruby, PHP). It reuses the existing `update_non_empty_string_with_fallback` helper (the one behind the `OTEL_SERVICE_NAME` alias), so only the global style is wired; extract/inject inherit it through the existing fallback in `propagation/config.rs`. Supported values: `datadog`, `tracecontext`, `baggage`, `b3` (single-header), `b3multi`, `none`. Unsupported OpenTelemetry propagators (`jaeger`, `xray`, `ottrace`) are dropped with a warning. `DD_TRACE_PROPAGATION_STYLE` wins when both are set. # Motivation Users who configure propagation via `OTEL_PROPAGATORS` expect dd-trace-rs to honor it the way the other tracers do. It was the only tracer (besides dd-trace-cpp) missing it. # Additional Notes - An empty `DD_TRACE_PROPAGATION_STYLE=""` is now treated as unset (falls back to `OTEL_PROPAGATORS`, then the default), consistent with the `OTEL_SERVICE_NAME` fallback. - Companion system-tests PR: DataDog/system-tests#7241. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: brian.marks <brian.marks@datadoghq.com>
What does this PR do?
Adds support for the OpenTelemetry
OTEL_PROPAGATORSenv var as a fallback forDD_TRACE_PROPAGATION_STYLE. WhenDD_TRACE_PROPAGATION_STYLEis unset, dd-trace-rs readsOTEL_PROPAGATORSand applies it to the global propagation style, matching the other Datadog tracers (Python, Go, Java, Node.js, .NET, Ruby, PHP).It reuses the existing
update_non_empty_string_with_fallbackhelper (the one behind theOTEL_SERVICE_NAMEalias), so only the global style is wired; extract/inject inherit it through the existing fallback inpropagation/config.rs. Supported values:datadog,tracecontext,baggage,b3(single-header),b3multi,none. Unsupported OpenTelemetry propagators (jaeger,xray,ottrace) are dropped with a warning.DD_TRACE_PROPAGATION_STYLEwins when both are set.Motivation
Users who configure propagation via
OTEL_PROPAGATORSexpect dd-trace-rs to honor it the way the other tracers do. It was the only tracer (besides dd-trace-cpp) missing it.Additional Notes
DD_TRACE_PROPAGATION_STYLE=""is now treated as unset (falls back toOTEL_PROPAGATORS, then the default), consistent with theOTEL_SERVICE_NAMEfallback.🤖 Generated with Claude Code