feat(tracer): wire OTLP span metrics into tracer flush path#4900
feat(tracer): wire OTLP span metrics into tracer flush path#4900rachelyangdog wants to merge 6 commits into
Conversation
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 92fe58f | Docs | Datadog PR Page | Give us feedback! |
Codecov Report❌ Patch coverage is Additional details and impacted files
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 539a23ef3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-07-02 20:23:14 Comparing candidate commit 92fe58f in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 325 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.
|
32cba4f to
043ce14
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 043ce14f49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
043ce14 to
fd2834e
Compare
053dd7f to
98e8123
Compare
fd2834e to
2e9aa5e
Compare
98e8123 to
167f231
Compare
2e9aa5e to
dc1c997
Compare
Config Audit |
167f231 to
6050a97
Compare
dc1c997 to
cd990d9
Compare
6050a97 to
3bada97
Compare
cd990d9 to
2ddc244
Compare
3bada97 to
7d13e46
Compare
2ddc244 to
af513d0
Compare
7d13e46 to
f6664fe
Compare
af513d0 to
03f9cb9
Compare
f6664fe to
6e23f98
Compare
03f9cb9 to
8fb20f9
Compare
6e23f98 to
08452dd
Compare
8fb20f9 to
b9861f0
Compare
08452dd to
563d9b2
Compare
b9861f0 to
b5fdd34
Compare
563d9b2 to
8c009d6
Compare
501931b to
2c25330
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c25330cfa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if c.internalConfig.OTLPSpanMetricsEnabled() { | ||
| // OTLP span metrics: SDK computes and exports stats; agent /v0.6/stats path unused. | ||
| sc = newOTLPMetricsConcentrator(c, statsd) |
There was a problem hiding this comment.
Document the OTLP span-metrics mode
The ddtrace/tracer/AGENTS.md guidance asks for doc.go updates when a significant tracer feature changes user-visible behavior. This new OTLP span-metrics branch changes stats/export behavior when OTLPSpanMetricsEnabled is true, but the commit does not update ddtrace/tracer/doc.go or related README documentation, so users have no tracer docs for enabling, disabling, or understanding the new metrics path.
Useful? React with 👍 / 👎.
1173824 to
d1699f0
Compare
… path (PR 4) - Add otlpExporter field to concentrator; flushAndSend branches to OTLP or native /v0.6/stats - Add newOTLPMetricsConcentrator constructor; select it in newUnstartedTracer when OTLPSpanMetricsEnabled - FR15: set Datadog-Client-Computed-Stats: yes header when OTLPSpanMetricsEnabled - FR15: append _dd.stats_computed=true resource attr on OTLP trace payloads - Fix sketchToHistogram to decode protobuf-serialized DDSketches (agent format) - Add SetOTLPSpanMetricsEnabled setter in internal/config for test wiring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ics flush interval Two bugs prevented OTLP span metrics from being exported in system tests: 1. _DD_TRACE_METRICS_OTEL_FLUSH_INTERVAL was read via env.Get() (allowlist), which returned "" for this internal-only override, defaulting to 10s. Switch to os.Getenv for this test-only internal variable. 2. tracer.Flush() called flushAndSend() directly while spans may still be pending in the concentrator's In channel (not yet processed by runIngester). Drain the In channel before flushing when includeCurrent=true so spans submitted just before Flush() are included in the export. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add otlpPeerTags to concentrator; inject span.kind="client" only when the span carries a peer-tag value (http.route, grpc.method.name) so non-top-level unmeasured spans are not made eligible via eligibleSpanKind - Set Datadog-Client-Computed-Stats header statically in transport headers when OTLPSpanMetricsEnabled so it is present from the first request - Pass transport headers to checkEndpoint startup probe so the header is included on the initial 0-trace-chunk connection check Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace for-loop map copy with maps.Copy in stats.go (mapsloop) - Replace bare int32/int64 atomic vars with atomic.Int32/Int64 types in otlp_transport_test.go and otlp_writer_test.go (atomictypes) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e as first-class field
_dd.stats_computed is a string-valued Datadog convention; change from BoolValue(true)
to StringValue("true") to match libdatadog and the system-test spec.
http.route (ext.HTTPRoute) is now captured as the HTTPEndpoint first-class field
with a fallback after ext.HTTPEndpoint, so OTel-instrumented spans get http.route
emitted as a data-point attribute via buildDataPointAttributes. Remove "http.route"
from otlpDefaultPeerTags since it had no effect on attribute emission (only grpc.method.name
peer tags are converted to attributes).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…port field Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2c25330 to
92fe58f
Compare
OTLP Span Metrics — Part 4 of 4: Tracer Integration
Wires the OTLP span metrics exporter into the tracer.
Stack order (merge in sequence):
otlp-span-metrics-config— configuration (PR feat(config): add OTLP span metrics config #4895)otlp-span-metrics-conversion— ClientStatsPayload → OTLP protobuf conversion (PR feat(tracer): stats to OTLP histogram conversion for OTLP span metrics #4897)otlp-span-metrics-transport— OTLP HTTP exporter (PR feat(tracer): add OTLP metrics HTTP exporter for span metrics #4899)What this PR does
Tracer integration (
tracer.go,stats.go):OTLPSpanMetricsEnabled=true, instantiates anewOTLPMetricsConcentratorinstead of the standard concentrator; this routes flushed stats to the OTLP endpoint rather than the agent's/v0.6/statspathPeer tag handling (
stats.go):otlpPeerTagsto the concentrator; when set, overrides agent-advertised peer tags with a fixed OTel-convention set (http.route,grpc.method.name)span.kind=clientonly when the span carries a peer-tag value, so non-top-level unmeasured spans are not incorrectly made eligible for stats computationDatadog-Client-Computed-Statsheader (option.go,log.go):OTLPSpanMetricsEnabled=true, ensuring it is present from the very first request (including the startup probe), before the agent/infopoll completesTesting
tests/parametric/test_otlp_trace_metrics.py— 44 passed, 2 xfailedotlp_metrics_wireup_test.goMotivation
Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.Unsure? Have a question? Request a review!