Skip to content

fix(trace-sampler): include a numeric http status code in the sampler signatures - #3716

Open
lucastemb wants to merge 3 commits into
mainfrom
lt/3578
Open

lucastemb wants to merge 3 commits into
mainfrom
lt/3578

Conversation

@lucastemb

@lucastemb lucastemb commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The rare sampler keeps a trace when a span has a signature it has not seen recently. An OTLP span stores its HTTP status code as a number, and the signature only read it as text, so two traces that differ only in status code, for example 200 and 404, shared a signature. The second one was dropped during the cooldown.

The signature now includes a numeric status code. Spans with a text status code, such as those from Datadog tracers, are hashed as before. The number of extra rare traces is bounded by the sampler's existing rate limit.

The same span hash also feeds the score and error samplers, so their signatures now separate these traces too. The Agent hashes the status code into all three, so this matches it.

Change Type

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

How did you test this PR?

  • Unit tests for the signature: different numeric codes differ, an integer and a whole-number float hash alike, invalid values (fractional, negative, out of range, NaN) are ignored, and a text code hashes as before.
  • A rare sampler test that two traces differing only in numeric status code are both kept.
  • cargo nextest run -p saluki-components on the trace sampler tests, cargo clippy -p saluki-components --tests, make fmt and make check-docs.
  • I removed the matching known difference from the otlp-traces-obfuscation-features correctness case. I did not run the case, because it needs Docker.

References

the signature read http.status_code only as a string, so an otlp span with a numeric code left the code out and two traces differing only in the code shared one signature. hash a numeric code in the range 100 to 599 as a four-byte integer. string codes still hash as text.
adp now keeps both feat.rare.status traces, so the case expects all 23 traces and spans.
@dd-octo-sts dd-octo-sts Bot added area/components Sources, transforms, and destinations. area/test All things testing: unit/integration, correctness, SMP regression, etc. transform/trace-sampler Trace Sampler synchronous transform. 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 20:42
@lucastemb
lucastemb requested a review from a team as a code owner December 4, 2026 20:42
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

AI review by Claude - workflow run

Patch is correct, with 0 blocking findings. A numeric http.status_code now goes into the span hash, so two OTLP traces that differ only in status code no longer share a rare-sampler signature. The open question is that the same hash also feeds the score sampler and the error sampler, and neither the title nor the description says so.


lib/saluki-components/src/transforms/trace_sampler/signature.rs L98

Not blocking: compute_span_hash also backs compute_signature_with_root_and_env. The score sampler (score_sampler.rs:102) and the error sampler (errors.rs:180) use that function. So OTLP traces with different numeric status codes now also get separate score and error signatures, not only separate rare signatures. This is probably the Agent's behavior too, because the Agent hashes the string tag for every signature. Is that intended? If so, I would say so in the title and description. We squash-merge, so the title becomes the commit title, and right now it only names the rare sampler.


lib/saluki-components/src/transforms/trace_sampler/signature.rs L53

Not blocking: take it or leave it. The sampler now imports from common::otlp::traces::transform only for these two bounds. That ties a generic sampler module to the OTLP translator. I would move MIN_HTTP_STATUS_CODE and MAX_HTTP_STATUS_CODE to a neutral shared place, such as common::datadog, and have both modules import them from there.


lib/saluki-components/src/transforms/trace_sampler/signature.rs L201

Nit: we import items instead of using paths like super::fnv1a_32_start and super::fnv1a_32_continue. Add both to the use super::{...} line at the top of the test module. The same applies at line 211.

@datadog-prod-us1-6 datadog-prod-us1-6 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

Numeric HTTP status codes now distinguish sampling signatures while preserving existing text-code hashing. No actionable defect was identified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit eda7c2e

Move the HTTP status code bounds to common::datadog so the sampler no longer imports from the OTLP translator, and import the hash helpers in the signature tests.
@lucastemb lucastemb changed the title fix(trace-sampler): include a numeric http status code in the rare sampler signature fix(trace-sampler): include a numeric http status code in the sampler signatures Dec 4, 2026
@lucastemb

lucastemb commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed in 23891ec: the status code bounds moved to common::datadog, and the signature tests import the hash helpers. The title and description now say the score and error signatures change too. That matches the Agent, whose computeSpanHash feeds all three.

This message was reviewed, approved by me, and sent on my behalf

@pr-commenter

pr-commenter Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Binary Size Analysis (Agent Data Plane)

Baseline: ca99ce7 · Comparison: 23891ec · diff
Analysis Configuration: optimized-release profile, stripped binaries · Pass/Fail Threshold: +5%
Sizes: 25.94 MiB (baseline) vs 25.94 MiB (comparison)
Size Change: +0 B (+0.00%)

✅ Binary size difference within threshold

Changes by Module
Module File Size Symbols
saluki_components::transforms::trace_sampler +250 B 1
[Unmapped] -200 B 1
[sections] -54 B 1
zstd +4 B 1
Detailed Symbol Changes
    FILE SIZE        VM SIZE    
 --------------  -------------- 
 +10.0%    +250 +10.0%    +250    saluki_components::transforms::trace_sampler::signature::compute_span_hash::h280caf0ac821d0bc
  +1.3%      +4  +1.3%      +4    zstd::stream::raw::Encoder::with_dictionary::h34614f189ff09f0e
  -0.0%     -54  -0.0%     -54    [section .text]
  -3.4%    -200  [ = ]       0    [Unmapped]
  [ = ]       0  +0.0%    +200    TOTAL

@pr-commenter

pr-commenter Bot commented Dec 4, 2026

Copy link
Copy Markdown

Regression Detector (Agent Data Plane)

Run ID: cee17c87-acb1-4ac6-9770-bf111624dda2
Baseline: ca99ce71 · Comparison: 23891ecb · 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_ultraheavy memory utilization ⚪ +2.16 metrics profiles logs
quality_gates_rss_dsd_medium memory utilization ⚪ +0.18 metrics profiles logs
quality_gates_rss_idle memory utilization ⚪ +0.14 metrics profiles logs
quality_gates_rss_dsd_low memory utilization ⚪ -0.04 metrics profiles logs
quality_gates_rss_dsd_heavy memory utilization ⚪ -0.28 metrics profiles logs
Bounds Checks: ✅ Passed (5)
experiment check replicates observed links
quality_gates_rss_dsd_heavy memory_usage 10/10 ✅ 175.42MiB ≤ 250MiB metrics profiles logs
quality_gates_rss_dsd_low memory_usage 10/10 ✅ 46.10MiB ≤ 55MiB metrics profiles logs
quality_gates_rss_dsd_medium memory_usage 10/10 ✅ 71.20MiB ≤ 92MiB metrics profiles logs
quality_gates_rss_dsd_ultraheavy memory_usage 10/10 ✅ 278.32MiB ≤ 420MiB metrics profiles logs
quality_gates_rss_idle memory_usage 10/10 ✅ 30.38MiB ≤ 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.

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/test All things testing: unit/integration, correctness, SMP regression, etc. changelog/no-changelog No changelog entry needed transform/trace-sampler Trace Sampler synchronous transform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traces(otlp): the rare sampler of ADP leaves the HTTP status code of an OTLP span out of the span signature

1 participant