Skip to content

feat!: root_span_id handling in otel thread ctx#1834

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits intomainfrom
yannham/thread-ctx-root-span-id
Apr 3, 2026
Merged

feat!: root_span_id handling in otel thread ctx#1834
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits intomainfrom
yannham/thread-ctx-root-span-id

Conversation

@yannham
Copy link
Copy Markdown
Contributor

@yannham yannham commented Apr 1, 2026

Depend on #1831.

What does this PR do?

Follow-up of #1791. Add special handling of the root_span_id attribute, which is expected to be always provided by downstream users of libdatadog when publishing a thread context.

Motivation

Addresses #1791 (comment).

Additional Notes

Since we want to set it automatically and unconditionally, I've opted for the convention that the corresponding key is always set and is always the first in the string table located in the process context. I believe this is reasonable (since we always want to set this attribute) and achievable as long as we control the process-level context publication. But it might be a tad "magic".

Another possibility is to request the user to provide the key for the datadog.root_span_id attribute. It is a bit less ergonomic for end-users who need to ensure the key is present, and propagate the index to the code that does the context switching so that it can provide it when calling into libdatadog.

How to test the change?

Tests have been updated to reflect the change.

@yannham yannham requested review from ivoanjo and scottgerring April 1, 2026 12:51
@yannham yannham requested review from a team as code owners April 1, 2026 12:51
@yannham yannham requested review from mabdinur and removed request for a team April 1, 2026 12:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/yannham/thread-ctx-root-span-id

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 55 55 No change (0%)
libdd-common 10 10 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 19 19 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 8 8 No change (0%)
libdd-trace-utils 15 15 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.

@yannham yannham changed the title feat: root_span_id handling in otel thread ctx feat!: root_span_id handling in otel thread ctx Apr 1, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.55%. Comparing base (11d4111) to head (a0d136d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1834      +/-   ##
==========================================
+ Coverage   71.48%   71.55%   +0.06%     
==========================================
  Files         426      426              
  Lines       67304    67350      +46     
==========================================
+ Hits        48113    48193      +80     
+ Misses      19191    19157      -34     
Components Coverage Δ
libdd-crashtracker 65.99% <ø> (ø)
libdd-crashtracker-ffi 34.09% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.20% <ø> (ø)
libdd-data-pipeline-ffi 72.22% <ø> (ø)
libdd-common 79.16% <ø> (ø)
libdd-common-ffi 73.87% <ø> (ø)
libdd-telemetry 62.80% <ø> (ø)
libdd-telemetry-ffi 16.75% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 73.10% <ø> (+2.10%) ⬆️
libdd-profiling 82.12% <100.00%> (+0.06%) ⬆️
libdd-profiling-ffi 64.94% <ø> (ø)
datadog-sidecar 31.18% <ø> (ø)
datdog-sidecar-ffi 11.84% <ø> (ø)
spawn-worker 54.69% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.24% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 88.73% <ø> (ø)
datadog-tracer-flare 86.88% <ø> (ø)
libdd-log 74.69% <ø> (ø)
🚀 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-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 Bot commented Apr 1, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 71.56% (+0.07%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a0d136d | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 1, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 102.12 MB 102.12 MB +0% (+8 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.76 MB 8.76 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 119.12 MB 119.12 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 11.36 MB 11.36 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 27.41 MB 27.41 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 80.69 KB 80.69 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 187.82 MB 187.81 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 924.52 MB 924.52 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 9.06 MB 9.06 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 80.69 KB 80.69 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 27.01 MB 27.01 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 61.33 MB 61.33 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 23.27 MB 23.27 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 81.94 KB 81.94 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 192.37 MB 192.36 MB -0% (-8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 909.66 MB 909.66 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.90 MB 6.90 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 81.94 KB 81.94 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 29.12 MB 29.12 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 57.70 MB 57.70 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 88.97 MB 88.97 MB +0% (+8 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 10.34 MB 10.34 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 111.78 MB 111.78 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.09 MB 12.09 MB 0% (0 B) 👌

Copy link
Copy Markdown
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Left a few notes! :)

Comment thread libdd-library-config/src/tracer_metadata.rs Outdated
Comment thread libdd-profiling/src/otel_thread_ctx.rs Outdated
Comment thread libdd-profiling/src/otel_thread_ctx.rs Outdated
Copy link
Copy Markdown
Member

@scottgerring scottgerring left a comment

Choose a reason for hiding this comment

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

ACK Ivo's comment about the local root span ID being passed as a [u8; 8] , but otherwise LGTM

@yannham yannham force-pushed the yannham/thread-ctx-attrs-keys branch from 0d88fe6 to cfba812 Compare April 2, 2026 10:34
Comment thread libdd-profiling/src/otel_thread_ctx.rs Outdated
@yannham yannham force-pushed the yannham/thread-ctx-root-span-id branch from c2bc9c6 to cc1162e Compare April 2, 2026 14:04
Base automatically changed from yannham/thread-ctx-attrs-keys to main April 2, 2026 14:48
@yannham yannham force-pushed the yannham/thread-ctx-root-span-id branch from cc1162e to 345d0c0 Compare April 2, 2026 14:51
Copy link
Copy Markdown
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

👍 LGTM

Comment thread libdd-profiling/src/otel_thread_ctx.rs
@yannham
Copy link
Copy Markdown
Contributor Author

yannham commented Apr 2, 2026

/remove

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

gh-worker-devflow-routing-ef8351 Bot commented Apr 2, 2026

View all feedbacks in Devflow UI.

2026-04-02 17:06:42 UTC ℹ️ Start processing command /remove


2026-04-02 17:06:47 UTC ℹ️ Devflow: /remove

@yannham
Copy link
Copy Markdown
Contributor Author

yannham commented Apr 3, 2026

Ready to merge, but waiting for #1843 to land which is currently blocking PHP, to avoid a rebase there.

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.

4 participants