Skip to content

fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* bool headers#2071

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
lpimentel/fix-client-computed-stats-bool-parsing
Jun 3, 2026
Merged

fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* bool headers#2071
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
lpimentel/fix-client-computed-stats-bool-parsing

Conversation

@lucaspimentel
Copy link
Copy Markdown
Member

@lucaspimentel lucaspimentel commented Jun 2, 2026

What does this PR do?

Fixes how libdd-trace-utils parses two "client-computed" boolean request headers when converting a HeaderMap into TracerHeaderTags, so the behavior matches the Go trace-agent:

  • Adds 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
  • Routes both datadog-client-computed-stats and datadog-client-computed-top-level through the helper.
  • Updates the doc comments on both struct fields to describe the Go-parity rule.

Motivation

The two headers were parsed differently from the Go trace-agent, causing disagreement on certain values:

  • client_computed_stats treated any non-empty value as true, so "0" and "false" wrongly resolved to true.
  • client_computed_top_level was set to true whenever 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 to false.

How to test the change?

Added table-driven unit tests in tracer_header_tags.rs covering 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 for is_header_true().

cargo nextest run -p libdd-trace-utils

All 189 tests pass (including the 4 Docker-dependent integration tests). cargo fmt --check and cargo clippy are clean.

"Turns out \"false\" meaning true was the only thing in this codebase that was being too positive." — Claude 🤖

APMSVLS-487

…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.
@lucaspimentel lucaspimentel changed the title fix(trace-utils): parse client-computed header bools like Go's isHead… fix(trace-utils): parse client-computed header bools like Go Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/lpimentel/fix-client-computed-stats-bool-parsing

Summary by Rule

Rule Base Branch PR Branch Change

Annotation Counts by File

File Base Branch PR Branch Change

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 21 21 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 3 3 No change (0%)
datadog-sidecar 57 57 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 13 13 No change (0%)
Total 196 196 No change (0%)

About This Report

This 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.

@lucaspimentel lucaspimentel changed the title fix(trace-utils): parse client-computed header bools like Go fix(trace-utils): match the Go agent when parsing client-computed headers Jun 2, 2026
@lucaspimentel lucaspimentel changed the title fix(trace-utils): match the Go agent when parsing client-computed headers fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* headers Jun 2, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.44%. Comparing base (a1da9fc) to head (3022bea).

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     
Components Coverage Δ
libdd-crashtracker 65.46% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 87.14% <ø> (+0.01%) ⬆️
libdd-data-pipeline-ffi 77.03% <ø> (ø)
libdd-common 79.89% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (-0.03%) ⬇️
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (ø)
libdd-profiling 81.69% <ø> (ø)
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.41% <ø> (ø)
datadog-sidecar 34.60% <ø> (ø)
datdog-sidecar-ffi 8.61% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.30% <100.00%> (+0.08%) ⬆️
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1 Bot commented Jun 2, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 73.44% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3022bea | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Jun 2, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 82.91 MB 82.91 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.26 MB 10.26 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 93.99 MB 93.99 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.54 MB 24.54 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 178.18 MB 178.17 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 913.88 MB 913.88 MB -0% (-4.04 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.03 MB 8.03 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.77 MB 23.77 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 47.42 MB 47.42 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.26 MB 21.26 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 182.11 MB 182.12 MB +0% (+8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 906.50 MB 906.50 MB -0% (-3.93 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.20 MB 6.20 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.48 MB 25.48 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.07 MB 45.07 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 73.94 MB 73.94 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.53 MB 8.53 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 89.34 MB 89.34 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.37 MB 10.37 MB 0% (0 B) 👌

@lucaspimentel lucaspimentel marked this pull request as ready for review June 3, 2026 17:40
@lucaspimentel lucaspimentel requested review from a team as code owners June 3, 2026 17:40
@lucaspimentel lucaspimentel requested a review from Copilot June 3, 2026 17:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, otherwise true).
  • Updates HeaderMap -> TracerHeaderTags conversion to route both “client-computed” headers through is_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.

@lucaspimentel
Copy link
Copy Markdown
Member Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Jun 3, 2026

View all feedbacks in Devflow UI.

2026-06-03 18:44:16 UTC ℹ️ Start processing command /merge


2026-06-03 18:44:21 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 47m (p90).


2026-06-03 19:27:00 UTC ℹ️ MergeQueue: This merge request was merged

@lucaspimentel lucaspimentel changed the title fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* headers fix(trace-utils): match the Go trace agent when parsing datadog-client-computed-* bool headers Jun 3, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 48da0d8 into main Jun 3, 2026
129 of 136 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the lpimentel/fix-client-computed-stats-bool-parsing branch June 3, 2026 19:26
iunanua added a commit that referenced this pull request Jun 5, 2026
# 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants