refactor(otel-thread-ctx): add const offset assertions for ThreadContextRecord#2018
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intoMay 20, 2026
Conversation
Contributor
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2018 +/- ##
==========================================
- Coverage 72.90% 72.88% -0.02%
==========================================
Files 457 457
Lines 75769 75769
==========================================
- Hits 55236 55226 -10
- Misses 20533 20543 +10
🚀 New features to boost your workflow:
|
Contributor
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: cc8f8fd | Docs | Datadog PR Page | Give us feedback! |
Contributor
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
|
paullegranddc
approved these changes
May 20, 2026
Base automatically changed from
yannham/otel-thread-ctx-polarsignals-review
to
main
May 20, 2026 16:58
…extRecord
Add compile-time offset_of assertions for every field of the
ThreadContextRecord struct, guarding against silent ABI breakage if
someone reorders or resizes fields in the future.
Move the existing size assertion out of `new()` into a top-level
`const _: () = { ... }` block next to the struct definition, so it
runs unconditionally at compile time regardless of code path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4c6affb to
cc8f8fd
Compare
gh-worker-dd-mergequeue-cf854d Bot
pushed a commit
that referenced
this pull request
May 21, 2026
#2019) # What does this PR do? Follow-up to #2018. Minor doc and style improvements in `libdd-otel-thread-ctx`. - Add a safety comment for the `unsafe` dereference in `ThreadContext::update()` - Fix `set_attrs` doc comment referencing `record.attrs_data` instead of `self.attrs_data` - Use `u8::try_from(val_len).unwrap_or_else(...)` for value length capping in `set_attrs`, making the `u8` invariant statically guaranteed instead of relying on a manual `if` + a comment # Motivation The `unsafe` block in `update()` lacked a safety justification. The `try_from` pattern eliminates the `as u8` cast and the stale comment that referenced a `min()` that didn't exist. # Additional Notes N/A # How to test the change? ``` cargo test -p libdd-otel-thread-ctx ``` All 8 existing tests pass unchanged. Co-authored-by: yann.hamdaoui <yann.hamdaoui@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Follow-up to #2016.
Adds compile-time
mem::offset_of!assertions for every field ofThreadContextRecord, catching accidental ABI breakage (field reordering, padding changes) at compile time rather than at runtime in a profiler.The existing size-only assertion from inside
new()is moved to a top-levelconst _: () = { ... }block next to the struct definition so it fires unconditionally regardless of code path.Motivation
ThreadContextRecordhas a fixed ABI read by out-of-process eBPF readers. The previous singlesize_of == 640check would still pass if fields were reordered without changing the total size. Per-field offset assertions make this impossible.Additional Notes
N/A
How to test the change?
N/A