feat(config): add OTLP trace export configuration support#4583
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files
🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: f0c6f00 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-03-25 17:10:52 Comparing candidate commit f0c6f00 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 216 metrics, 8 unstable metrics.
|
… to determine otlp mode
9882338 to
8188bbe
Compare
| if c.internalConfig.TraceProtocol() == traceProtocolV1 && !af.v1ProtocolAvailable { | ||
| c.internalConfig.SetTraceProtocol(traceProtocolV04, internalconfig.OriginCalculated) | ||
| } | ||
| if c.internalConfig.TraceProtocol() == traceProtocolV1 { | ||
| if t, ok := c.transport.(*httpTransport); ok { | ||
| t.traceURL = fmt.Sprintf("%s%s", agentURL.String(), tracesAPIPathV1) | ||
| t.traceURL = agentURL.String() + tracesAPIPath |
There was a problem hiding this comment.
Just wondering, should this be able to mutate the URL when we are in OTLP mode ?
There was a problem hiding this comment.
Technically, it shouldnt.
DD_TRACE_AGENT_PROTOCOL_VERSION takes precedence over "otlp mode" config. And we are only in this "if" block if the user has explicitly configured DD_TRACE_AGENT_PROTOCOL_VERSION="1.0"
Co-authored-by: Benjamin De Bernardi <[email protected]>
What does this PR do?
Adds configuration support for OTLP trace export mode. Actual OTLP trace export implementation will be done in a follow-up PR.
When
OTEL_TRACES_EXPORTER=otlpis set, the tracer uses a separate OTLP collector endpoint and OTLP-specific headers instead of the standard Datadog agent trace endpoint.Key changes:
otlpExportModeon internal/config.Config based onOTEL_TRACES_EXPORTER=otlp. When set, this toggles a new "otlp mode"otlpTraceURL, andotlpHeadersfields on internal/config.Config, with getters/setters.otlpTraceURLis resolved from OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (or defaults to agentHost:4318/v1/traces) and is fully independent of agentURL.newHTTPTransportto accept fully resolved traceURL, statsURL, and headers, making it agnostic to Datadog vs OTLP mode.Motivation
This is the configuration groundwork for supporting OTLP trace export. By centralizing URL/header resolution in internal/config and making the transport layer protocol-agnostic, the actual OTLP serialization (converting Datadog spans to the OTLP wire format) can be added in a follow-up PR with minimal additional plumbing.
Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.Unsure? Have a question? Request a review!