Skip to content

feat(config): add OTLP trace export configuration support#4583

Merged
mtoffl01 merged 19 commits into
mainfrom
mtoff/otlp-export-config
Mar 25, 2026
Merged

feat(config): add OTLP trace export configuration support#4583
mtoffl01 merged 19 commits into
mainfrom
mtoff/otlp-export-config

Conversation

@mtoffl01

@mtoffl01 mtoffl01 commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

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=otlp is set, the tracer uses a separate OTLP collector endpoint and OTLP-specific headers instead of the standard Datadog agent trace endpoint.

Key changes:

  • Introduces otlpExportMode on internal/config.Config based on OTEL_TRACES_EXPORTER=otlp. When set, this toggles a new "otlp mode"
  • Introduces otlpTraceURL, and otlpHeaders fields on internal/config.Config, with getters/setters. otlpTraceURL is resolved from OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (or defaults to agentHost:4318/v1/traces) and is fully independent of agentURL.
  • Refactors newHTTPTransport to 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

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

@codecov

codecov Bot commented Mar 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.88235% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.65%. Comparing base (5d005fa) to head (f0c6f00).

Files with missing lines Patch % Lines
internal/config/provider/provider.go 44.44% 5 Missing ⚠️
internal/config/config_helpers.go 84.21% 1 Missing and 2 partials ⚠️
ddtrace/tracer/transport.go 83.33% 2 Missing ⚠️
internal/config/provider/otelenvconfigsource.go 66.66% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/option.go 84.13% <100.00%> (ø)
ddtrace/tracer/tracer.go 88.35% <100.00%> (ø)
internal/config/config.go 60.88% <100.00%> (+60.88%) ⬆️
ddtrace/tracer/transport.go 87.62% <83.33%> (ø)
internal/config/provider/otelenvconfigsource.go 88.31% <66.66%> (ø)
internal/config/config_helpers.go 51.35% <84.21%> (ø)
internal/config/provider/provider.go 71.11% <44.44%> (ø)

... and 430 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 23, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 84.93%
Overall Coverage: 60.03% (+4.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f0c6f00 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter

pr-commenter Bot commented Mar 23, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-25 17:10:52

Comparing candidate commit f0c6f00 in PR branch mtoff/otlp-export-config with baseline commit 5d005fa in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 216 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@mtoffl01 mtoffl01 changed the title (2) feat(tracer): Support otlp export feat(tracer, config): Support all OTLP export configurations Mar 23, 2026
@mtoffl01 mtoffl01 changed the title feat(tracer, config): Support all OTLP export configurations feat(config): add OTLP trace export configuration support Mar 23, 2026
@mtoffl01
mtoffl01 marked this pull request as ready for review March 23, 2026 18:46
@mtoffl01
mtoffl01 requested review from a team as code owners March 23, 2026 18:46

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@genesor genesor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, few questions

Comment thread internal/config/provider/provider.go Outdated
Comment thread internal/config/config_helpers.go Outdated
Comment thread internal/config/config_test.go Outdated
Comment thread ddtrace/tracer/option.go
Comment on lines +462 to +465
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just wondering, should this be able to mutate the URL when we are in OTLP mode ?

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.

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"

@mtoffl01
mtoffl01 enabled auto-merge (squash) March 25, 2026 16:43
@mtoffl01
mtoffl01 merged commit 944319d into main Mar 25, 2026
208 checks passed
@mtoffl01
mtoffl01 deleted the mtoff/otlp-export-config branch March 25, 2026 17:12
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.

3 participants