fix(otlp): emit otel.scope.name and otel.scope.version span meta - #2099
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75e8a51a1e
ℹ️ 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".
Binary Size Analysis (Agent Data Plane)Baseline: 6c17562 · Comparison: 200a5ff · diff ✅ Binary size difference within thresholdChanges by Module
Detailed Symbol Changes |
This comment has been minimized.
This comment has been minimized.
Regression Detector (Agent Data Plane)Run ID: Optimization Goals: ✅ No significant changes detectedFine details of change detection per experiment (5)Experiments configured
Bounds Checks: ✅ Passed (5)
ExplanationA change is flagged as a regression when |Δ mean %| > 5.00% in the regressing direction for its optimization goal AND SMP marks the experiment as a regression ( |
…ted behavior Adds a minimal AgentVersion parser to datadog-agent-commons and plumbs DD_AGENT_VERSION from the CI build through the Docker image so ADP can read it at runtime. Components call agent_version::meets(major, minor, patch) to conditionally emit behavior matching the bundled Agent version. Details: - DD_AGENT_VERSION is set to the release tag (e.g. "7.81.0-full") for regular CI builds and to "nightly" for nightly CI builds using the dev Agent. - When DD_AGENT_VERSION is unset (standalone / local dev), version gates default to the most recent behavior. - Development builds (nightly, devel, master) always satisfy every gate. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
ADP was emitting only the deprecated otel.library.* span metadata, omitting the current otel.scope.* keys that the Datadog Agent started emitting between 7.81.0 and 7.83.0-devel. Uses the Agent version gate introduced in datadog-agent-commons to match the behavior of whichever Agent version ADP is bundled with, keeping both regular CI (pinned release) and nightly CI (dev Agent) green against their respective baselines. TODO: confirm exact public Agent release and update the threshold (currently 7.82.0) in transform.rs. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
5374f65 to
2a466a8
Compare
…of runtime Addresses review feedback: rather than reading DD_AGENT_VERSION from the process environment at runtime, bake it into the binary at compile time via build.rs (mirroring how saluki-metadata embeds APP_* metadata). - build.rs reads DD_AGENT_VERSION and emits parsed version constants. - agent_version::meets() / version() now use those compile-time constants; the OnceLock and std::env::var runtime read are removed. - The ADP image build (Dockerfile.agent-data-plane + .gitlab/build.yml) passes DD_AGENT_VERSION into the cargo build: "nightly" for nightly CI, the pinned public release version otherwise. - Removes the now-unnecessary runtime env injection from the converged Agent image (Dockerfile.datadog-agent) and .gitlab/e2e.yml. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…cript Replace the double-substitution idiom with a plain if/else for readability. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds version_string() to datadog-agent-commons::agent_version to expose the raw DD_AGENT_VERSION baked-in string, then surfaces it as "Built Against Agent Version" in ADP's GetStatusDetails response so it appears in Core Agent's `agent status`. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…docs Replace Latin abbreviations and misspelling flagged by the Vale prose linter: - "e.g." → "for example" - "i.e." → "that is" - "parseable" → "parsable" → reworded to avoid the ambiguity Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…a-plane The prior commit's lockfile inadvertently reverted agent-data-plane from 1.4.0 to 1.3.0. Regenerate so the only change vs. the base is the added datadog-agent-commons dependency for saluki-components. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Since DD_AGENT_VERSION is baked in at build time, version() / meets() can be const fn — callers can evaluate gates in a const context so the compiler resolves the outcome statically and eliminates the dead branch. AgentVersion::meets uses a manual lexicographic comparison of the three components since tuple PartialOrd is not usable in const fn. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Now that agent_version::meets is a const fn, hoist the gate into a module-level const (EMIT_OTEL_SCOPE_META) computed once at compile time, instead of calling the gate twice per span on the transform hot path. Addresses Copilot review feedback on duplication and hot-path cost. Also make the unit test key its expectation off EMIT_OTEL_SCOPE_META and assert the emitted values, so it stays correct regardless of the DD_AGENT_VERSION the crate was built with. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…pe keys Build the otel.library.*/otel.scope.* value once per field and clone it (cheap for MetaString-backed values) instead of converting the source string twice. Addresses Copilot review feedback on hot-path allocations. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The constant was wedged into the middle of the *_META_KEY string-constant block, splitting it awkwardly. Move it below DD_NAMESPACED_TO_APM_CONVENTIONS into its own labeled section for version-gated behavior toggles, where future overrides can live. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…or (#2106) ## Summary Introduces a minimal Agent version gate in `datadog-agent-commons` so ADP can conditionally reproduce version-specific Agent behavior matching the Agent it is bundled with. This is the infrastructure PR; the first consumer is in the stacked OTLP PR. `DD_AGENT_VERSION` is baked into the converged image at build time (release tag for regular CI, `"nightly"` for nightly CI) and read by ADP at startup via `agent_version::version()`. Any component calls `agent_version::meets(major, minor, patch)` to gate behavior. When the variable is unset (standalone / local dev), gates default to the most recent behavior. See example usage in the stacked PR: #2099 ## Test plan - [x] 7 unit tests for `AgentVersion::parse` / `meets` covering release tags, dev builds, bare dev markers, and edge cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: jesse.szwedko <jesse.szwedko@datadoghq.com>
There was a problem hiding this comment.
More details
The PR correctly adds version-gated support for otel.scope.{name,version} span metadata, emitted only when the bundled Agent is 7.82.0+ (resolved at compile time). The implementation maintains backward compatibility by always emitting deprecated otel.library.* keys. Build-time constants, proper empty-scope checks, and test coverage that mirrors the gate logic ensure both CI contexts (7.81.0 baseline and nightly) pass as intended, with no runtime regressions.
📊 Validated against 12 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 200a5ff · What is Autotest? · Any feedback? Reach out in #autotest
Summary
ADP was emitting only the deprecated
otel.library.*span metadata, omittingotel.scope.name/otel.scope.versionthat the Datadog Agent started emitting in 7.82.0. Naively adding the keys unconditionally breaks regular MR CI (which validates against the pinned 7.81.0 baseline that doesn't emit them yet) while fixing nightly CI (which validates against the dev Agent that does).Uses the Agent version gate from PR #2106 (
datadog-agent-commons::agent_version::meets) to emit the keys only when the bundled Agent version is 7.82.0+, keeping both CI contexts green against their respective baselines.Test plan
test_otel_span_to_dd_span_scope_name_version_metaverifies bothotel.library.*(always) andotel.scope.*(when version unknown → defaults to latest) are emitted🤖 Generated with Claude Code