feat(ddtrace/tracer): diagnose and report the trace protocol in use - #5168
Conversation
Config Audit |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 50e4756 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-08-14 13:48:36 Comparing candidate commit 50e4756 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 335 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.
|
9055f8b to
dbaf763
Compare
6a1a745 to
d18ad8e
Compare
d196c45 to
57c08b9
Compare
logTraceProtocolDowngrade gated its Warn/Debug split on agentFeatures.reachable, which is false both when /info never answers (unknown v1 support) and when it answers 404 (pre-7.28 agent, provably no v1 support, since /v1.0/traces support postdates /info support). An explicit DD_TRACE_AGENT_PROTOCOL_VERSION=1.0 against a reachable-but-too-old agent therefore silently fell back to v0.4 without the warning this diagnostic exists to provide. Thread the fetchAgentFeatures error through loadAgentFeatures so logTraceProtocolDowngrade can distinguish the two cases with errors.Is(err, errAgentFeaturesNotSupported), matching the distinction refreshAgentFeatures already makes for the runtime re-evaluation path. Flagged by Codex review on #5150.
…s active ReportEffectiveTraceProtocol and logTraceProtocolDowngrade ran unconditionally, but agentEnabled (which gates the /info poll) does not exclude CI Visibility, OTLP export, or the writer-selection chain in newUnstartedTracer. In those modes no Datadog v0.4/v1.0 trace payload is ever sent, so deriving a wire protocol from the agent's /info response and reporting it as DD_TRACE_AGENT_PROTOCOL_VERSION could misreport a value that contradicts the user's explicit setting, and a denied v1 could log a misleading warning. Adds usesAgentTraceWriter, mirroring the writer-selection if/else chain in newUnstartedTracer, and gates both the startup and runtime (refreshAgentFeatures) report/log call sites on it.
…iters
startupInfo.TraceProtocol derived a Datadog v0.4/v1.0 wire protocol from
the agent's /info snapshot unconditionally, even when OTLP export, CI
Visibility, or log-to-stdout mode selects a non-agent trace writer that
never sends a Datadog payload. With no reachable agent this reported
"0.4" purely from effectiveTraceProtocol's fallback, misleading anyone
diagnosing startup config from the log.
Reports traceProtocolNotApplicable ("n/a") instead when
usesAgentTraceWriter is false. Updates the pre-existing "lambda" startup
log test, which had encoded the bug (LogToStdout mode reporting "0.4")
as expected behavior.
d18ad8e to
50e4756
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50e4756f09
ℹ️ 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".
| // log-to-stdout, OTLP export): the protocol derived from this /info | ||
| // response would be meaningless there and could misreport a value that | ||
| // contradicts the user's explicit setting. | ||
| logTraceProtocolDowngrade(c, agentURL, agentDisabled || !c.usesAgentTraceWriter(), errors.Is(agentErr, errAgentFeaturesNotSupported)) |
There was a problem hiding this comment.
Handle v1 denial discovered after startup
When DD_TRACE_AGENT_PROTOCOL_VERSION=1.0 and /info is unreachable during startup, this call correctly suppresses the warning because support is unknown, but it is the only invocation of the new downgrade diagnostic. If a later agent-info poll reaches an Agent that omits v1 or returns 404, refreshAgentFeatures only logs when ReportEffectiveTraceProtocol changes; because startup already recorded the fallback as v0.4, that call returns false and the now-confirmed denial remains silent. Invoke equivalent, deduplicated denial logging when a poll first establishes that v1 is unavailable.
Useful? React with 👍 / 👎.
What does this PR do?
This is the diagnostics follow-up to #5167, stacked above the runtime capability work.
It makes the selected Datadog trace protocol observable without conflating it with client-side stats:
/infoAgent case;n/a, rather than a Datadog wire protocol, for OTLP, CI Visibility, and log-to-stdout writers.Validation
go test ./ddtrace/tracer -run 'TraceProtocol|PayloadRotates|UsesAgentTraceWriter|PinTestTracerToV04' -count=1