Skip to content

feat(traces): add OTLP http/json trace export#251

Draft
bm1549 wants to merge 2 commits into
mainfrom
brian.marks/otlp-trace-export
Draft

feat(traces): add OTLP http/json trace export#251
bm1549 wants to merge 2 commits into
mainfrom
brian.marks/otlp-trace-export

Conversation

@bm1549

@bm1549 bm1549 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds OTLP trace export to dd-trace-rs. When OTEL_TRACES_EXPORTER=otlp is set, finished trace chunks are exported over OTLP http/json to an OpenTelemetry collector instead of the Datadog agent's MessagePack endpoint, by wiring libdatadog's TraceExporter OTLP path (set_otlp_endpoint / set_otlp_headers / set_connection_timeout). This mirrors the existing metrics/logs OTLP wiring.

Configuration (parsed and reported via config telemetry; headers excluded as sensitive):

  • OTEL_TRACES_EXPORTERotlp enables OTLP export; none disables tracing
  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT → fallback OTEL_EXPORTER_OTLP_ENDPOINT + /v1/traces → default http://<agent_host>:4318/v1/traces
  • OTEL_EXPORTER_OTLP_TRACES_HEADERS / _TIMEOUT (10s) / _PROTOCOL (only http/json honored this phase; warns otherwise)
  • OTEL_TRACES_SAMPLER / _ARG mapped to a sample rate with a parentbased fallback

Behavior: DD_TRACE_AGENT_PROTOCOL_VERSION disables OTLP; DD_TRACE_SAMPLE_RATE/DD_TRACE_SAMPLING_RULES take precedence over the OTel sampler; only sampled spans are exported (libdatadog drop_chunks); the agent URL is kept separate so /info, Remote Config, and telemetry keep talking to the agent.

Motivation

Part of the cross-language OTLP Traces Export effort (RFC "OTLP Traces Export 2026Q1", Phase 1): let the Datadog SDK emit traces over OTLP for users running an OpenTelemetry collector. Rust uses the same libdatadog exporter as dd-trace-py.

Additional Notes

~22 unit + integration tests (config resolution, gates, sampler mapping, real http/json POST to /v1/traces, unsampled-drop); cargo fmt and cargo clippy clean across all feature combinations. Scope is RFC Phase 1: http/json only — no gRPC, no W3C TraceContext L2 / TraceState probability sampling, no trace stats, no OTel semantic conventions.

Related PRs (cross-language OTLP traces export — system-tests validates all three tracers):

Merge order: libdatadog #2101 → dd-trace-php #3971 (re-bump the submodule to the released libdatadog commit). system-tests #7121 validates rust/ruby/php once the tracer branches are available.

🤖 Generated with Claude Code

Route Datadog trace chunks through libdd-data-pipeline's TraceExporter OTLP
http/json path when OTEL_TRACES_EXPORTER=otlp, mirroring the existing metrics
and logs OTLP integration in the datadog-opentelemetry crate.

Configuration:
- OTEL_TRACES_EXPORTER (otlp enables OTLP export; none disables tracing)
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, with fallback to
  OTEL_EXPORTER_OTLP_ENDPOINT (strip trailing slash, append /v1/traces) and a
  computed default http://<agent_host>:4318/v1/traces (host derived from the
  resolved trace-agent URL, matching the metrics/logs helpers)
- OTEL_EXPORTER_OTLP_TRACES_HEADERS (fallback OTEL_EXPORTER_OTLP_HEADERS;
  sensitive, excluded from config telemetry)
- OTEL_EXPORTER_OTLP_TRACES_TIMEOUT (fallback OTEL_EXPORTER_OTLP_TIMEOUT)
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL (parsed and reported; only http/json is
  honored this phase, a warning is logged otherwise)
- OTEL_TRACES_SAMPLER / OTEL_TRACES_SAMPLER_ARG mapped to a Datadog sample rate
- DD_TRACE_AGENT_PROTOCOL_VERSION disables OTLP export when set

The agent URL stays separate from the OTLP endpoint so /info, Remote Config,
and telemetry keep talking to the Datadog agent. libdatadog drops unsampled
(priority < 1) chunks before OTLP send, so only sampled spans are exported.

Adds config-resolution unit tests (endpoint fallback, header parsing, timeout
resolution, gates, sampler mapping/validation) and an in-repo integration test
that emits a span with no external OpenTelemetry SDK setup and asserts the OTLP
http/json payload reaches a local HTTP endpoint, plus that dropped spans are
not exported.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@datadog-prod-us1-4

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

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Check Pull Request CI Status | ensure-ci-success   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

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

validate_supported_configurations_v2 failed: the new config entries used
placeholder version 'A' / default null. Match the registry: DD_TRACE_AGENT_PROTOCOL_VERSION
default 0.4 (A); OTEL_EXPORTER_OTLP_TRACES_PROTOCOL B; OTEL_TRACES_EXPORTER C
(string exporter selector); OTEL_TRACES_SAMPLER E. Doc-only — the generated
config map and runtime defaults are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.

1 participant