Skip to content

fix(otel-metrics): skip spans with client-computed stats - #54280

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
munir/otel-skip-client-computed-stats
Aug 20, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
munir/otel-skip-client-computed-stats

Conversation

@mabdinur

@mabdinur mabdinur commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What

Datadog tracing libraries can emit spans as OTLP while also computing APM stats client-side
(CSS). Those spans carry _dd.stats_computed as a resource or span attribute.

Before this PR, the DDOT connector did not inspect that marker. It converted the spans and
recomputed hits, errors, and duration, double-counting stats the tracing library had already
produced.

After this PR, the connector treats _dd.stats_computed as a ResourceSpans-level signal. When
the marker is truthy on the resource or any span it contains, every span in that ResourceSpans
is excluded from the connector's concentrator. Other resources in the same OTLP batch remain
eligible for Agent-computed stats.

Why resource scope is correct

  • Client-side stats are enabled or disabled for the whole ddtrace client; there is no partial
    per-span enablement.
  • The ddtrace OTLP path emits _dd.stats_computed as a resource attribute.
  • The Agent and built-in collector processors preserve or copy the resource and its attributes
    when forwarding, batching, splitting, or regrouping trace data.

One marked span is therefore sufficient evidence for its containing ResourceSpans, but not for
other resources that happen to share the same ptrace.Traces payload.

Changes

  • Detect _dd.stats_computed on both resource and span attributes.
  • Promote a span-level marker to its containing ResourceSpans.
  • Skip every span belonging to a client-computed resource while retaining unmarked resources.
  • Return before span indexing and top-level detection when the entire payload is client-computed.
  • Allocate the computed-resource set only when a marker is found.
  • Treat absent, empty, or false markers as not client-computed; other non-empty values enable
    the skip.

Performance

The same focused benchmark was run at the PR's base commit and current head on an Apple M4 Max
with GOMAXPROCS=1. The payload contains 10 resources with 10 spans each.

Scenario Before PR After PR Result
Client stats enabled ~281.6 us/op ~0.82 us/op ~344x faster
Client stats disabled ~282.5 us/op ~283.7 us/op +0.4%, within benchmark noise

With client stats enabled, memory falls from 114,808 B/op to 712 B/op and allocations from 855 to
5. With client stats disabled, memory and allocations are unchanged at 114,808 B/op and 855
allocations/op.

The added no-marker resource scan measures approximately 0.50 us per 100 spans with zero
allocations. That is about 0.18% of the baseline conversion cost, or roughly 5 ns per span for this
payload.

Validation

bazel test //pkg/trace/otel/stats:stats_test
bazel test //comp/otelcol/otlp/components/connector/datadogconnector:datadogconnector_test

Both targets pass. Tests cover marker parsing, resource-level markers, promotion of a span marker
to its containing resource, and retaining unmarked resources in the same payload.

Spans carrying _dd.stats_computed already have SDK-computed APM stats; skip them in the concentrator input so the datadog/connector doesn't double-count hits/errors/duration alongside the SDK trace remap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/opentelemetry OpenTelemetry team team/agent-build labels Jul 30, 2026
@github-actions github-actions Bot added the short review PR is simple enough to be reviewed quickly label Jul 30, 2026
@mabdinur mabdinur added the qa/done QA done before merge and regressions are covered by tests label Jul 30, 2026
@datadog-official

datadog-official Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 52.34% (+0.04%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 24d543a | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor efa5d8ab:

Results for datadog-agent_7.84.0~devel.git.55.24d543a.pipeline.130206309-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.84.0~devel.git.55.24d543a.pipeline.130206309-1_amd64.deb:

No change detected

@dd-octo-sts

dd-octo-sts Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor efa5d8a
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
docker_agent_amd64 +3.03 KiB (0.00% increase, -0.16% of buffer) 818.158 → 818.161 → 819.970
docker_agent_arm64 +5.42 KiB (0.00% increase, -0.35% of buffer) 819.162 → 819.167 → 820.690
docker_agent_jmx_amd64 +3.05 KiB (0.00% increase, -0.18% of buffer) 1009.055 → 1009.058 → 1010.730
docker_agent_jmx_arm64 +5.41 KiB (0.00% increase, -0.32% of buffer) 998.712 → 998.717 → 1000.370
docker_host_profiler_amd64 +7.25 KiB (0.00% increase, -0.06% of buffer) 305.801 → 305.808 → 317.690
docker_host_profiler_arm64 +7.24 KiB (0.00% increase, -0.06% of buffer) 317.116 → 317.123 → 328.970
27 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_deb_amd64 759.545 MiB
agent_deb_amd64_fips 712.883 MiB
agent_heroku_amd64 312.273 MiB
agent_msi 643.246 MiB
agent_rpm_amd64 759.529 MiB
agent_rpm_amd64_fips 712.867 MiB
agent_rpm_arm64 735.492 MiB
agent_rpm_arm64_fips 692.101 MiB
agent_suse_amd64 759.529 MiB
agent_suse_amd64_fips 712.867 MiB
agent_suse_arm64 735.492 MiB
agent_suse_arm64_fips 692.101 MiB
docker_cluster_agent_amd64 210.228 MiB
docker_cluster_agent_arm64 223.268 MiB
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.479 MiB
docker_dogstatsd_arm64 37.560 MiB
dogstatsd_deb_amd64 30.220 MiB
dogstatsd_deb_arm64 28.243 MiB
dogstatsd_rpm_amd64 30.220 MiB
dogstatsd_suse_amd64 30.220 MiB
iot_agent_deb_amd64 46.416 MiB
iot_agent_deb_arm64 43.091 MiB
iot_agent_deb_armhf 43.871 MiB
iot_agent_rpm_amd64 46.416 MiB
iot_agent_suse_amd64 46.415 MiB

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 30, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: b2aae965-7abc-4d2d-b66d-e8feff2acce5

Baseline: eb756d8
Comparison: 000d4ef
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_metrics_logs memory utilization +0.70 [+0.46, +0.93] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization +0.48 [+0.43, +0.53] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization +0.29 [+0.20, +0.38] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization +0.15 [+0.11, +0.19] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -0.00 [-0.03, +0.03] 1 Logs bounds checks dashboard
quality_gate_private_action_runner memory utilization -0.08 [-0.20, +0.04] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization -0.31 [-0.35, -0.28] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -0.46 [-1.33, +0.40] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 173.77MiB ≤ 178MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 745.18KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 512.86MiB ≤ 538MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.14MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 19 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 215.89MiB ≤ 229MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 263.51MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 365.02 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 20 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 433.49MiB ≤ 453MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 72.05MiB ≤ 76MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 28.40 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 325.89MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 62.06 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 302.54MiB ≤ 314MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 22.69 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 309.35MiB ≤ 343MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.

…n first-span marker

Detect client-computed stats via _dd.stats_computed on the span itself in
addition to the resource, and short-circuit the whole payload when the
marker is on the first span, mirroring the native OTLP receiver's
header-based all-or-nothing behavior instead of filtering span by span.
@github-actions github-actions Bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Aug 6, 2026
An OTLP payload can bundle spans from multiple resources, so a CSS
marker on the first span says nothing about the rest. Rely only on
the per-resource/per-span check, which is the only granularity the
marker actually guarantees.
@github-actions github-actions Bot added short review PR is simple enough to be reviewed quickly and removed medium review PR review might take time labels Aug 6, 2026
The native OTLP receiver (pkg/trace/api/otlp.go) resolves
_dd.stats_computed once per ResourceSpans, not per span. Mirror that
here: memoize the resource-level check instead of re-parsing the same
resource attributes for every span it contains.
@github-actions github-actions Bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Aug 10, 2026
@mabdinur
mabdinur marked this pull request as ready for review August 10, 2026 20:52
@mabdinur
mabdinur requested review from a team as code owners August 10, 2026 20:52
@github-actions github-actions Bot deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@mabdinur

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd297c51c7

ℹ️ 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".

Comment thread pkg/trace/otel/stats/otel_util_test.go Outdated
@mabdinur

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 10, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-10 23:07:28 UTC ℹ️ Start processing command /merge


2026-08-10 23:07:35 UTC ℹ️ MergeQueue: Pull request is not mergeable yet

It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.

  • Run /code blockers to see what is blocking it.
  • Run /remove to cancel it.

2026-08-11 00:39:12 UTC ⚠️ MergeQueue: This merge request was unqueued

munir.abdinur@datadoghq.com unqueued this merge request

@mabdinur mabdinur added the ask-review Ask in slack required teams to review this PR label Aug 14, 2026
@mabdinur

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 20, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-20 19:16:44 UTC ℹ️ Start processing command /merge


2026-08-20 19:16:49 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 2h (p90).


2026-08-20 20:30:06 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 000d4ef into main Aug 20, 2026
315 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the munir/otel-skip-client-computed-stats branch August 20, 2026 20:30
@github-actions github-actions Bot added this to the 7.84.0 milestone Aug 20, 2026
@mabdinur mabdinur changed the title fix(otel-metrics): skip client-computed spans in OTLP stats concentrator fix(otel-metrics): skip spans with client-computed stats in OTLP stats connector Aug 21, 2026
@mabdinur mabdinur changed the title fix(otel-metrics): skip spans with client-computed stats in OTLP stats connector fix(otel-metrics): skip spans with client-computed stats Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ask-review Ask in slack required teams to review this PR changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time qa/done QA done before merge and regressions are covered by tests qa/skip-qa team/agent-build team/opentelemetry OpenTelemetry team team/opentelemetry-agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants