Skip to content

feat(otel-thread-ctx)!: publish W3C trace flags - #2298

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
PROF-15584-support-w-3-c-trace-flags-libdatadog
Jul 30, 2026
Merged

feat(otel-thread-ctx)!: publish W3C trace flags#2298
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
PROF-15584-support-w-3-c-trace-flags-libdatadog

Conversation

@morrisonlevi

Copy link
Copy Markdown
Contributor

What does this PR do?

Store the W3C trace-flags byte at offset 25 and pass it through the Rust and C APIs during construction and in-place updates.

BREAKING CHANGES: these functions now require a trace_flags argument:

  • ThreadContext::new
  • ThreadContext::update
  • ddog_otel_thread_ctx_new
  • ddog_otel_thread_ctx_update

Motivation

The spec changed after the context work was initially done in libdatadog.

Additional Notes

PHP will use this in an upstream PR.

How to test the change?

Update your APIs for the above functions to include the trace flags, then proceed as normal.

Store the W3C trace-flags byte at offset 25 and pass it through the Rust and
C APIs during construction and in-place updates.

BREAKING CHANGE: ThreadContext::new, ThreadContext::update,
ddog_otel_thread_ctx_new, and ddog_otel_thread_ctx_update now require a
trace_flags argument.
@pr-commenter

pr-commenter Bot commented Jul 29, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Candidate

Candidate benchmark details

Baseline

Baseline benchmark details

@datadog-official

datadog-official Bot commented Jul 29, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 88.64%
Overall Coverage: 74.80% (-0.01%)

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

@dd-octo-sts

dd-octo-sts Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.01 MB 8.01 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 87.33 MB 87.33 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 98.56 MB 98.56 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.78 MB 10.78 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 26.05 MB 26.05 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 89.60 KB 89.60 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.11 MB 188.12 MB +0% (+8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 981.00 MB 981.00 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.49 MB 8.49 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 89.60 KB 89.60 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 25.10 MB 25.10 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.93 MB 49.93 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.69 MB 22.69 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 91.00 KB 91.00 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 192.91 MB 192.89 MB --.01% (-24.00 KB) 💪
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 968.83 MB 968.83 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.56 MB 6.56 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 91.00 KB 91.00 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.97 MB 26.97 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 47.53 MB 47.53 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 77.86 MB 77.86 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.93 MB 8.93 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 93.35 MB 93.35 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.87 MB 10.87 MB 0% (0 B) 👌

@morrisonlevi
morrisonlevi marked this pull request as ready for review July 29, 2026 22:09
@morrisonlevi
morrisonlevi requested a review from a team as a code owner July 29, 2026 22:09

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 LGTM thanks for the addition

(For extra context -- the W3C trace flags field was a late addition to the spec, we had one leftover reserved byte and it was decided that we'd repurpose it for carrying those flags. The eBPF Profiler doesn't yet do anything with this data, but in the future it might...)

Comment thread libdd-otel-thread-ctx/src/lib.rs Outdated
let root_span_id = [3u8; 8];

ThreadContext::new(trace_id, span_id, root_span_id, &[]).attach();
ThreadContext::new(trace_id, span_id, 0, root_span_id, &[]).attach();

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.

Nit: should 0 be a named constant like NO_FLAGS or something? To make the default value more discoverable. Another possibility, if those flags are rarely set, is to keep the original interface but have a with_flags API. Though it doesn't really work for updates as well...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ergonomic improvements e.g. NO_FLAGS are possible but kind of limited because these things go over into FFI as well, and then you end up with having to name something like DDOG_OTEL_THREAD_CTX_NO_TRACE_FLAGS or something similarly horrible.

But if you mean for the sake of readability in tests, sure, NO_FLAGS is fine.

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.

Right, agreed on the FFI part - and I suppose it's so idiomatic in C that it probably doesn't deserve a constant on the C side... Yeah, I was thinking test but also the few potential pure Rust API consumers, like dd-trace-rs, or tracers that re-use libdatadog à la carte

@morrisonlevi

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 30, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-30 14:12:51 UTC ℹ️ Start processing command /merge


2026-07-30 14:12:57 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 1h (p90).


2026-07-30 14:58:54 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 5761c06 into main Jul 30, 2026
91 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the PROF-15584-support-w-3-c-trace-flags-libdatadog branch July 30, 2026 14:58
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.

3 participants