Skip to content

feat(config): support OTEL_PROPAGATORS as propagation style fallback#271

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
brian.marks/otel-propagators
Jul 6, 2026
Merged

feat(config): support OTEL_PROPAGATORS as propagation style fallback#271
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
mainfrom
brian.marks/otel-propagators

Conversation

@bm1549

@bm1549 bm1549 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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

🤖 Generated with Claude Code

bm1549 and others added 5 commits June 30, 2026 16:32
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>
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 30, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9667a09 | Docs | Datadog PR Page | Give us feedback!

bm1549 and others added 2 commits June 30, 2026 17:11
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>
@bm1549 bm1549 marked this pull request as ready for review July 2, 2026 18:52
@bm1549 bm1549 requested a review from a team as a code owner July 2, 2026 18:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +1359 to +1361
trace_propagation_style: cisu.update_non_empty_string_with_fallback(
default.trace_propagation_style,
SupportedConfigurations::OTEL_PROPAGATORS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 iunanua left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment thread datadog-opentelemetry/src/core/configuration/configuration.rs Outdated
// 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")],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>
@bm1549

bm1549 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@iunanua Dug into this - it's mostly harness gaps, not missing OTEL vars. The test_otel_env_vars.py cases assert on dd_trace_sample_rate (the rust parametric /trace/config returns null), and the test_telemetry.py cases need the otel.env.hiding/otel.env.invalid metrics that aren't wired up here - so enabling them is a follow-up, out of scope for this PR.

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit e2d2e95 into main Jul 6, 2026
35 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the brian.marks/otel-propagators branch July 6, 2026 15:53
Aaalibaba42 pushed a commit that referenced this pull request Jul 8, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants