feat(traces): add OTLP http/json trace export#251
Draft
bm1549 wants to merge 2 commits into
Draft
Conversation
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>
|
This was referenced Jun 10, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds OTLP trace export to dd-trace-rs. When
OTEL_TRACES_EXPORTER=otlpis 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'sTraceExporterOTLP 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_EXPORTER—otlpenables OTLP export;nonedisables tracingOTEL_EXPORTER_OTLP_TRACES_ENDPOINT→ fallbackOTEL_EXPORTER_OTLP_ENDPOINT+/v1/traces→ defaulthttp://<agent_host>:4318/v1/tracesOTEL_EXPORTER_OTLP_TRACES_HEADERS/_TIMEOUT(10s) /_PROTOCOL(onlyhttp/jsonhonored this phase; warns otherwise)OTEL_TRACES_SAMPLER/_ARGmapped to a sample rate with a parentbased fallbackBehavior:
DD_TRACE_AGENT_PROTOCOL_VERSIONdisables OTLP;DD_TRACE_SAMPLE_RATE/DD_TRACE_SAMPLING_RULEStake precedence over the OTel sampler; only sampled spans are exported (libdatadogdrop_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 fmtandcargo clippyclean 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