feat(otel-thread-ctx)!: add self check capability#2095
Conversation
…SDESC The linker can optimize TLSDESC to Local Exec, so a positive TLSDESC check is too strict. Instead, assert that no General Dynamic or Local Dynamic relocations (DTPMOD/DTPOFF) are present for otel_thread_ctx_v1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract check_tls_slot_in(path) from check_tls_slot_present() so the integration test can call the same programmatic checks instead of shelling out to readelf. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 804db1d | Docs | Datadog PR Page | Give us feedback! |
📚 Documentation Check Results📦
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06bb468de7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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. |
🔒 Cargo Deny Results📦
|
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
|
The previous check only forbade GD/LD relocations (DTPMOD/DTPOFF), missing other TLS relocation types like TPOFF64 or GOTTPOFF. Flip from a blocklist to an allowlist: only TLSDESC is accepted. Rename check_no_gd_ld_reloc -> check_tlsdesc_reloc_only accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
What does this PR do?
This PR adds a self-test capability to libdd-otel-thread-ctx (and to the FFI), for both shared libraries and statically linked executables. The test checks that the TLS symbol is visible in the dynsym table of the library, and that the model is TLSDESC
Motivation
OTel thread context requires a specific linking setup, which if not met, makes the context non-discoverable and thus the whole feature unusable. It's thus useful, at least for the CI and post-build sanity checks of downstream profilers to be able to verify that a build is functional.
Additional Notes
The PR is feature-gated so that the
readelfdependency isn't pulled if the check is not useful (typically, it can be peformed at build time but be skipped from the final tracer/profiler if desired).How to test the change?
The existing test has been refactored to use that code (instead of commands). I've checked that removing the TLSDESC dialect configuration option from the linker, or removing the dynamic list which doesn't export the symbol, make the test fail with the expected error message.