Add OTLP http/json trace export (OTEL_TRACES_EXPORTER=otlp)#5888
Draft
bm1549 wants to merge 2 commits into
Draft
Add OTLP http/json trace export (OTEL_TRACES_EXPORTER=otlp)#5888bm1549 wants to merge 2 commits into
bm1549 wants to merge 2 commits into
Conversation
Export finished traces over OTLP http/json instead of Datadog MessagePack when OTEL_TRACES_EXPORTER=otlp. The exporter is hand-rolled in pure Ruby (modeled on dd-trace-js), reusing the gem's JSON and Net::HTTP facilities; no opentelemetry-exporter-otlp dependency is added on the trace path. - New pure-Ruby OTLP transport: encoder (DD -> OTLP span/resource/scope JSON), Net::HTTP exporter, and a transport implementing the Writer's send_traces contract. - Config settings + env mapping under tracing.otlp: endpoint (+ fallback), headers (+ fallback, sensitive), timeout, protocol. Endpoint precedence: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, else OTEL_EXPORTER_OTLP_ENDPOINT with /v1/traces appended, else http://<agent_host>:4318/v1/traces. - Exporter selection in Component#build_writer. Gated off when DD_TRACE_AGENT_PROTOCOL_VERSION is set (logs a notice). Agent /info, Remote Config, and telemetry continue to use the agent URL. - Reuses the existing OTEL_TRACES_SAMPLER -> DD_TRACE_SAMPLE_RATE mapping; only sampled traces (priority >= AUTO_KEEP) are exported. - RBS signatures, supported-configurations entries, GettingStarted/OTel docs. - RSpec coverage for encoding shape, endpoint/header/timeout resolution, the protocol-version disable gate, and unsampled-drop. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Stop logging the misleading 'Traces will be sent to Datadog' warning when OTEL_TRACES_EXPORTER=otlp (the documented value); tracing stays enabled and the OTLP exporter is selected via tracing.otlp. - Add OTLP::Response#service_rates (nil) so the writer's after-send priority-sampler callback short-circuits instead of raising/swallowing a NoMethodError on every flush. - Warn (not fail) when a non-http/json OTLP protocol is configured, matching dd-trace-rs, so a protocol misconfiguration isn't a silent no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Typing analysisNote: Ignored files are excluded from the next sections.
|
This was referenced Jun 10, 2026
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 0e8eeaf | Docs | Datadog PR Page | Give us feedback! |
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 http/json trace export to the
datadoggem. WhenOTEL_TRACES_EXPORTER=otlpis set, finished traces are exported over OTLP http/json to an OpenTelemetry collector instead of the Datadog agent. The exporter is hand-rolled in pure Ruby (no new heavy dependency), wired intoTracing::Component#build_writeras an alternate transport, mirroring dd-trace-js.Configuration (
tracing.otlpsettings + env mapping):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/_ARG(reuses the existing mapping)Behavior:
DD_TRACE_AGENT_PROTOCOL_VERSIONdisables OTLP;DD_TRACE_SAMPLE_RATE/rules take precedence; only sampled spans are exported; the agent transport (and Remote Config //info) is unaffected when OTLP is off.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.
Change log entry
Yes. Add OTLP trace export: set
OTEL_TRACES_EXPORTER=otlpto export traces over OTLP (http/json) to an OpenTelemetry collector.Additional Notes:
Yes — the AI-generated code was read and understood. 47+ OTLP-specific specs plus config/gate specs (374 examples in the combined run, 0 failures); RBS signatures added; StandardRB/Steep clean. Scope is RFC Phase 1: http/json only (no gRPC, no W3C TraceContext L2 / probability sampling, no trace stats, no OTel semantic conventions).
How to test the change?
Covered by new RSpec specs under
spec/datadog/tracing/transport/otlp*. End-to-end coverage is added in system-tests (Test_Otel_Tracing_OTLP, activated for ruby). Manually: setOTEL_TRACES_EXPORTER=otlpandOTEL_EXPORTER_OTLP_TRACES_ENDPOINTto a collector and confirm spans arrive as OTLP http/json.Related PRs (cross-language OTLP traces export):
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