Skip to content

fix(otlp): keep spans whose trace id high halves differ instead of dropping them - #3717

Open
lucastemb wants to merge 8 commits into
mainfrom
lt/3445
Open

lucastemb wants to merge 8 commits into
mainfrom
lt/3445

Conversation

@lucastemb

@lucastemb lucastemb commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An OTLP trace ID has a high and a low 64-bit half. When spans of one payload shared the low half but had different high halves, ADP dropped the whole group. That happens in real traffic when a hop that only understands 64-bit IDs drops the high half, so one trace arrives with some spans at (0, low) and others at (high, low). Dropping them lost the whole trace.

Now spans that share the low half stay in one trace when their high halves are equal or either is zero, and the trace takes the non-zero high half. Spans are split into separate traces only when both high halves are non-zero and differ. Each span also keeps the otel.trace_id tag of its own ID. The drop reason for invalid IDs is renamed from foreign_span to invalid_trace_id.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

How did you test this PR?

  • Translator unit tests through translate_spans: a zero and a non-zero high half merge into one trace in either order, two different non-zero high halves give two traces, a zero-high span joins the first non-zero trace, the same ID gives one trace, a dropped span only affects its own trace, and each span carries its own otel.trace_id.
  • cargo nextest run -p saluki-components on the OTLP and sampler tests, cargo nextest run -p otlp-fixtures, cargo clippy -p saluki-components --tests, make fmt and make check-docs.
  • I removed the matching known difference from the otlp-traces-conversion correctness case and kept its colliding-ID probes. I did not run the case, because it needs Docker.

References

spans whose trace ids differ in the high half are different traces. the
translator used to group by the low half only and drop the whole group when
the high halves differed. it now keeps one trace per full trace id.
the case compares the low half of the trace id only, so it cannot show
spans that split into separate traces by high half. the unit tests of the
translator cover the split. a control probe with one full trace id stays.
@dd-octo-sts dd-octo-sts Bot added area/components Sources, transforms, and destinations. area/docs Reference documentation. area/test All things testing: unit/integration, correctness, SMP regression, etc. labels Dec 4, 2026
@lucastemb lucastemb added the changelog/no-changelog No changelog entry needed label Dec 4, 2026
@lucastemb
lucastemb marked this pull request as ready for review December 4, 2026 21:14
@lucastemb
lucastemb requested a review from a team as a code owner December 4, 2026 21:14
@pr-commenter

pr-commenter Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Binary Size Analysis (Agent Data Plane)

Baseline: 8c80abe · Comparison: 67a22ed · diff
Analysis Configuration: optimized-release profile, stripped binaries · Pass/Fail Threshold: +5%
Sizes: 25.96 MiB (baseline) vs 25.96 MiB (comparison)
Size Change: +4.00 KiB (+0.02%)

✅ Binary size difference within threshold

Changes by Module
Module File Size Symbols
saluki_components::common::otlp +2.07 KiB 9
hashbrown +1.40 KiB 6
faster_hex +861 B 1
[Unmapped] -524 B 1
[sections] +289 B 4
saluki_core::runtime::workers -184 B 2
core +98 B 32
zstd +4 B 1
saluki_components::sources::otlp +0 B 8
axum +0 B 42
axum_core +0 B 2
tower +0 B 16
alloc +0 B 4
Detailed Symbol Changes
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [NEW] +49.7Ki  [NEW] +49.7Ki    saluki_components::common::otlp::OtlpServerConfiguration::build::_{{closure}}::h31ac96628fcdc175
  [NEW] +48.4Ki  [NEW] +48.4Ki    saluki_components::common::otlp::traces::translator::OtlpTracesTranslator::translate_spans::h014ec15f9a0a08cd
  [NEW] +38.9Ki  [NEW] +38.9Ki    saluki_core::runtime::workers::FnWorker::new::_{{closure}}::_{{closure}}::h9584a30351686e07
  [NEW] +21.1Ki  [NEW] +21.1Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::translate_metrics_inner::h845d0b0c4f613c07
  [NEW] +19.7Ki  [NEW] +19.7Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::map_to_dd_format::hef0ff58ef1f70d7e
  [NEW] +13.0Ki  [NEW] +13.0Ki    saluki_components::sources::otlp::logs::translator::OtlpLogsTranslator::translate_logs::hb4d27eda79a3ab02
  [NEW] +3.74Ki  [NEW] +3.74Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::h5bcd0014d74bf146
  +0.1% +2.83Ki  +0.1% +3.34Ki    [108 Others]
  [NEW] +3.07Ki  [NEW] +3.07Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::h13bd142773631daa
  [NEW] +3.07Ki  [NEW] +3.07Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::h8a36cf37d9085b66
  [NEW] +2.82Ki  [NEW] +2.82Ki    saluki_components::common::otlp::traces::transform::normalize_peer_service_tag::hd690899167b51d65
  [DEL] -2.82Ki  [DEL] -2.82Ki    saluki_components::common::otlp::traces::transform::normalize_peer_service_tag::h1dcb9ee080a6f5b0
  [DEL] -3.07Ki  [DEL] -3.07Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::h8a7fe1a14a736d0d
  [DEL] -3.07Ki  [DEL] -3.07Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::had7d60b4b593a423
  [DEL] -3.74Ki  [DEL] -3.74Ki    _<F as axum::handler::Handler<$LP$M,T1,T2$RP$,S>>::call::_{{closure}}::he89930b7e9416b5f
  [DEL] -13.0Ki  [DEL] -13.0Ki    saluki_components::sources::otlp::logs::translator::OtlpLogsTranslator::translate_logs::h9803d1f08dba7515
  [DEL] -19.7Ki  [DEL] -19.7Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::map_to_dd_format::h723d19f4ef7ee2d3
  [DEL] -21.1Ki  [DEL] -21.1Ki    saluki_components::sources::otlp::metrics::translator::OtlpMetricsTranslator::translate_metrics_inner::h8f95bf33e08e703a
  [DEL] -39.1Ki  [DEL] -39.1Ki    saluki_core::runtime::workers::FnWorker::new::_{{closure}}::_{{closure}}::h3e63bd76a31a2db0
  [DEL] -47.1Ki  [DEL] -47.1Ki    saluki_components::common::otlp::traces::translator::OtlpTracesTranslator::translate_spans::hed7e937a569f3f3c
  [DEL] -49.7Ki  [DEL] -49.7Ki    saluki_components::common::otlp::OtlpServerConfiguration::build::_{{closure}}::h44e5a95fe933dcbf
  +0.0% +4.00Ki  +0.0% +4.51Ki    TOTAL

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review by Claude - workflow run

Patch is correct, with 0 blocking findings. Grouping by the full (high, low) trace ID fixes the drop in #3445, and the new unit tests cover the split. The open questions are about Agent parity in chunk shape, the drop metric's tag that no longer fits, and the correctness coverage that this PR removes.

@datadog-official datadog-official 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.

Bits Code Review: PASS

More details

The full 128-bit trace ID is used consistently for grouping and emission, keeping traces with matching low halves separate. The completed static review returned no actionable findings.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 64fae74

the low 64 bits identify a trace and the high 64 bits are an optional
extension that a hop of 64-bit ids drops. spans that share a low half now
share a trace when their high halves are equal or either one is zero.
only two different non-zero high halves split them, and a zero-high span
joins the first non-zero trace by order of first appearance.
the counter now only counts spans of a trace with an invalid trace id: a
length other than 0 or 16 bytes, or a zero low half. the reason tag and the
accessor name that cause.
spans of one trace can now carry different high halves. the hex form of the
trace id that a span carries in otel.trace_id came from the first span of
its trace, so a span with another high half named the wrong id. a span now
reuses that string only when its high half is the same.
the spans that share a low half and differ in their high half now stay in one
trace, so both sides keep them and the case pairs them. the probes check that
adp no longer drops them. the counts follow the fixture: 88 spans in 81
traces reach each side.
@lucastemb lucastemb changed the title fix(otlp): group traces by the full 128-bit trace id fix(otlp): keep spans whose trace id high halves differ instead of dropping them Dec 4, 2026
@pr-commenter

pr-commenter Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Regression Detector (Agent Data Plane)

Run ID: 0c59399a-13c6-4310-86ab-0a5eaa4a894f
Baseline: 8c80abeb · Comparison: 67a22ed5 · diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment (5)

Experiments configured erratic: true are tagged (ignored) and skipped when determining which experiments regressed or improved. Experiments which are detected as erratic at runtime are tagged (erratic) to flag that the run's sample dispersion was high, but their regression / improvement signal still counts.

experiment goal Δ mean % links
quality_gates_rss_dsd_medium memory utilization ⚪ +0.38 metrics profiles logs
quality_gates_rss_dsd_heavy memory utilization ⚪ -0.05 metrics profiles logs
quality_gates_rss_idle memory utilization ⚪ -0.08 metrics profiles logs
quality_gates_rss_dsd_low memory utilization ⚪ -0.13 metrics profiles logs
quality_gates_rss_dsd_ultraheavy memory utilization ⚪ -1.15 metrics profiles logs
Bounds Checks: ✅ Passed (5)
experiment check replicates observed links
quality_gates_rss_dsd_heavy memory_usage 10/10 ✅ 158.97MiB ≤ 250MiB metrics profiles logs
quality_gates_rss_dsd_low memory_usage 10/10 ✅ 46.50MiB ≤ 55MiB metrics profiles logs
quality_gates_rss_dsd_medium memory_usage 10/10 ✅ 70.91MiB ≤ 92MiB metrics profiles logs
quality_gates_rss_dsd_ultraheavy memory_usage 10/10 ✅ 290.94MiB ≤ 420MiB metrics profiles logs
quality_gates_rss_idle memory_usage 10/10 ✅ 30.04MiB ≤ 36MiB metrics profiles logs
Explanation

A 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 (is_regression: true). Improvements use the matching criteria for the improving direction. Experiments configured erratic: true (tagged (ignored)) are skipped outright; experiments detected as erratic at runtime (tagged (erratic)) still count, since that flag describes sample dispersion rather than directional certainty. The Δ mean % cell is colored accordingly: 🟢 = improvement, 🔴 = regression, ⚪ = neutral. Reduction in CPU or memory is an improvement; reduction in ingress throughput is a regression. Experiments tagged (no analysis) show ⚠️ n/a: SMP ran them but produced no analysis, usually because a replicate failed and exhausted its retries. Check the SMP report for that experiment's replicate failures.

@datadog-official datadog-official 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.

Bits Code Review: FAIL

The PR prevents collision-related OTLP span loss, preserves zero-high-half compatibility, and restores collision fixtures. Two new performance regressions remain open: quadratic grouping for large batches sharing a low half, and repeated trace-ID string allocations in mixed-high traces; the earlier review had no open findings.

Open Bits AI session

🤖 Bits Code Review · Commit 05ae23e

Find the trace of a span with a non-zero high half by its full trace ID instead of scanning the traces that share its low half, so a request with many high halves for one low half no longer costs a quadratic scan. A zero high half still joins the first trace of its low half. Cache the hex trace ID per kind of high half, so spans of a trace with a mixed high half share a string too.

@datadog-official datadog-official 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.

Bits Code Review: PASS

More details

The PR prevents collision-related OTLP span loss while preserving zero-high-half compatibility and restoring collision fixtures. Indexed group lookup eliminates quadratic scanning, and separate zero/nonzero trace-ID string caches eliminate repeated allocations, resolving both earlier findings; no findings remain open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 10db081

…n difference

The mixed_a and mixed_b probes share a low trace id half and have two different non-zero high halves. ADP puts them in two traces on purpose, so the root of the second trace carries _dd.p.dm, and the Agent's single chunk does not.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/components Sources, transforms, and destinations. area/docs Reference documentation. area/test All things testing: unit/integration, correctness, SMP regression, etc. changelog/no-changelog No changelog entry needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traces(otlp): ADP drops spans of a trace group whose high trace ID halves differ

1 participant