fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* bool headers#2071
Conversation
…erTrue The datadog-client-computed-stats and datadog-client-computed-top-level headers were parsed differently from the Go trace-agent: - client_computed_stats treated any non-empty value as true, so "0" and "false" wrongly resolved to true. - client_computed_top_level was set true whenever the header was present (even with value "false"). Add an is_header_true() helper mirroring the Go trace-agent's isHeaderTrue (pkg/trace/api/api.go): empty -> false; the false-like values strconv.ParseBool recognizes (0/f/F/false/False/FALSE) -> false; every other non-empty value (including unparseable ones like "yes") -> true. Route both headers through it and add table-driven tests.
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
datadog-client-computed-* headers
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2071 +/- ##
==========================================
+ Coverage 73.42% 73.44% +0.02%
==========================================
Files 465 465
Lines 77949 78007 +58
==========================================
+ Hits 57231 57290 +59
+ Misses 20718 20717 -1
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 3022bea | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
There was a problem hiding this comment.
Pull request overview
Aligns libdd-trace-utils header parsing for datadog-client-computed-stats and datadog-client-computed-top-level with the Go trace-agent’s isHeaderTrue semantics when converting HeaderMap into TracerHeaderTags.
Changes:
- Adds an
is_header_true()helper implementing Go-parity boolean parsing (empty/explicit-false literals →false, otherwisetrue). - Updates
HeaderMap -> TracerHeaderTagsconversion to route both “client-computed” headers throughis_header_true(). - Updates field comments and adds table-driven unit tests covering the new parsing behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
datadog-client-computed-* headersdatadog-client-computed-* bool headers
48da0d8
into
main
# Release proposal for libdd-sampling and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-trace-utils **Next version:** `7.0.0` **Semver bump:** `major` **Tag:** `libdd-trace-utils-v7.0.0` ### Commits - feat(trace-utils)!: add dedup convenience to VecMap (#2049) - fix(trace-utils): match the Go trace agent when parsing `datadog-client-computed-*` bool headers (#2071) - revert!: add from_string to span text (#2011) (#2073) - fix(send_with_retry): follow max retries of the strategy (#2047) ## libdd-sampling (manually bumped due to breaking in #2073) **Next version:** ~~`2.1.1`~~ `3.0.0` **Semver bump:** ~~`patch`~~ `major` **Tag:** ~~`libdd-sampling-v2.1.1`~~ `libdd-sampling-v3.0.0` ### Commits - fix(sampling): format _dd.p.ksr to 6 decimal places, not 6 significant digits (#2086) - revert!: add from_string to span text (#2011) (#2073) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com> Co-authored-by: iunanua <igor.unanua@datadoghq.com>
What does this PR do?
Fixes how
libdd-trace-utilsparses two "client-computed" boolean request headers when converting aHeaderMapintoTracerHeaderTags, so the behavior matches the Go trace-agent:is_header_true()helper mirroring the Go trace-agent'sisHeaderTrue(pkg/trace/api/api.go):falsestrconv.ParseBoolrecognizes (0,f,F,false,False,FALSE) →falseyes) →truedatadog-client-computed-statsanddatadog-client-computed-top-levelthrough the helper.Motivation
The two headers were parsed differently from the Go trace-agent, causing disagreement on certain values:
client_computed_statstreated any non-empty value astrue, so"0"and"false"wrongly resolved totrue.client_computed_top_levelwas set totruewhenever the header was merely present (even with value"false").Additional Notes
The subtle rule is that unparseable values default to
true(so"yes"/"no"→true); only the explicit false-like literals and empty resolve tofalse.How to test the change?
Added table-driven unit tests in
tracer_header_tags.rscovering both headers for true values (1 t T TRUE true True yes no maybe 2), false values (0 f F FALSE False false), empty string, and not-set, plus a direct unit test foris_header_true().All 189 tests pass (including the 4 Docker-dependent integration tests).
cargo fmt --checkandcargo clippyare clean.APMSVLS-487