Skip to content

Support the OTEP-4947 trace-flags byte - #404

Merged
szegedi merged 1 commit into
mainfrom
szegedi/trace-flags
Sep 1, 2026
Merged

Support the OTEP-4947 trace-flags byte#404
szegedi merged 1 commit into
mainfrom
szegedi/trace-flags

Conversation

@szegedi

@szegedi szegedi commented Aug 28, 2026

Copy link
Copy Markdown

When we started working on the Otel Thread Context support, the record had a reserved field, but when OTEP-4797 was finalized, it became a trace-flags byte (offset 25), which OTEP-4947 defines as the
W3C trace-flags. We need to catch up with this change.

API change

new ThreadContext(traceId, spanId, attributes?)
new ThreadContext(traceId, spanId, traceFlags?, attributes?)

traceFlags goes third, next to the ids it describes, rather than being appended after attributes. This will break callers passing attributes positionally; TypeScript rejects it at compile time, and at runtime an array in slot 3 throws
traceFlags must be an integer in 0..255. It's okay to break callers, as dd-trace-js is the only known consumer at the moment and we can make the matching change when we release pprof-nodejs.

Any integer in 0..255 is accepted rather than masked to the two bits W3C currently defines, because W3C requires unknown flag bits to be propagated. Absent / undefined / null means 0, which is what OTEP-4947 prescribes when no flags are known.

setTraceFlags()

A constructor argument alone would not be enough. dd-trace's sampling decision is deferred, so it should be possible to set the value later.

@github-actions

Copy link
Copy Markdown

Overall package size

Self size: 2.58 MB
Deduped: 3.28 MB
No deduping: 3.28 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | pprof-format | 2.3.1 | 504.33 kB | 504.33 kB | | source-map | 0.8.0 | 185.66 kB | 185.66 kB | | node-gyp-build | 4.8.4 | 13.86 kB | 13.86 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-datadog-us1-prod

This comment has been minimized.

@szegedi szegedi added the semver-minor Usually minor non-breaking improvements label Aug 28, 2026
@szegedi
szegedi marked this pull request as ready for review August 28, 2026 14:08
@szegedi
szegedi merged commit 091babc into main Sep 1, 2026
125 of 129 checks passed
@szegedi
szegedi deleted the szegedi/trace-flags branch September 1, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor Usually minor non-breaking improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants