Skip to content

feat(otel-thread-ctx)!: add self check capability#2095

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 17 commits into
mainfrom
yannham/thread-ctx-autocheck
Jun 29, 2026
Merged

feat(otel-thread-ctx)!: add self check capability#2095
gh-worker-dd-mergequeue-cf854d[bot] merged 17 commits into
mainfrom
yannham/thread-ctx-autocheck

Conversation

@yannham

@yannham yannham commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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 readelf dependency 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.

@yannham yannham requested a review from ivoanjo June 8, 2026 13:36
@yannham yannham requested review from a team as code owners June 8, 2026 13:36
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 60.00%
Overall Coverage: 74.01% (-0.04%)

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

@yannham yannham changed the title feat!(otel-thread-ctx)!: add shared lib sanity check feat(otel-thread-ctx)!: add shared lib sanity check Jun 8, 2026
@yannham yannham changed the title feat(otel-thread-ctx)!: add shared lib sanity check feat(otel-thread-ctx)!: add self check capability Jun 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread libdd-otel-thread-ctx-ffi/src/lib.rs Outdated
Comment thread libdd-otel-thread-ctx/src/sanity_check.rs Outdated
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/yannham/thread-ctx-autocheck

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 22 22 No change (0%)
datadog-live-debugger 4 4 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-sidecar 45 45 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 6 6 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-remote-config 3 3 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 11 11 No change (0%)
Total 182 182 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.

@dd-octo-sts

dd-octo-sts Bot commented Jun 8, 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 7.82 MB 7.82 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 85.14 MB 85.14 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 96.27 MB 96.27 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.51 MB 10.51 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.14 MB 25.14 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 88.04 KB 88.04 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 183.34 MB 183.34 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 938.86 MB 938.86 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.22 MB 8.22 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 88.04 KB 88.04 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.30 MB 24.30 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 48.47 MB 48.47 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.79 MB 21.79 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.42 KB 89.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 187.39 MB 187.37 MB -0% (-16.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 927.44 MB 927.44 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.35 MB 6.35 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.42 KB 89.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.09 MB 26.09 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.11 MB 46.11 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 75.88 MB 75.88 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.70 MB 8.70 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.34 MB 91.34 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.59 MB 10.59 MB 0% (0 B) 👌

@ivoanjo

ivoanjo commented Jun 17, 2026

Copy link
Copy Markdown
Member

I'm curious -- how would this interact with #2129 ?

@yannham

yannham commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

#2129 should be an internal and feature-preserving refactoring that doesn't change anything from the reader side, so the implementation of this sanity check doesn't depend in any way on whether #2129 is used or not (we basically just read our own elf like an external reader), and #2129 should ideally pass the sanity check once it lands as well.

@yannham yannham force-pushed the yannham/thread-ctx-autocheck branch from 02b5f05 to 804db1d Compare June 19, 2026 15:37
@yannham yannham requested a review from scottgerring June 22, 2026 08:29
@yannham yannham force-pushed the yannham/thread-ctx-autocheck branch from 804db1d to 84b36fe Compare June 22, 2026 08:30

@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 this looks good! Thanks for the patience with my extremely slow review 😅

It might be worth getting a second quick pass from @scottgerring or @nsavoire since they've been spending a lot more time on the elf details than I have, but I'd say not a blocker (e.g. they can give a pass after we merge too)

Comment thread libdd-otel-thread-ctx-ffi/Cargo.toml

@scottgerring scottgerring 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.

cool idea!
couple nits but lgtm

Comment thread libdd-otel-thread-ctx/src/sanity_check.rs Outdated
Comment thread libdd-otel-thread-ctx-ffi/src/lib.rs
yannham and others added 10 commits June 25, 2026 15:42
…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>
yannham and others added 6 commits June 25, 2026 15:42
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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yannham yannham force-pushed the yannham/thread-ctx-autocheck branch from d7f067a to ddf086c Compare June 25, 2026 13:42
@yannham

yannham commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 25, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-25 13:46:50 UTC ℹ️ Start processing command /merge


2026-06-25 13:46:58 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-25 14:47:14 UTC ℹ️ MergeQueue: merge request added to the queue

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


2026-06-25 15:52:57 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit 92480d3:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@ivoanjo

ivoanjo commented Jun 29, 2026

Copy link
Copy Markdown
Member

@yannham I'm going to go ahead and re-add this to the merge queue, hope that's fine with you ;)

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit af3902d into main Jun 29, 2026
99 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the yannham/thread-ctx-autocheck branch June 29, 2026 14:42
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Jun 29, 2026
## chore: release v37.0.0

Bumps the workspace version from `36.0.0` to `37.0.0` in `Cargo.toml` and regenerates `Cargo.lock`.

## Post-merge steps

1. Trigger the `create_release` job on GitLab — builds artifacts and creates a draft GitHub release.
2. Ask someone from `libdatadog-core` or `libdatadog-release` to publish the draft release.
3. Trigger the `release-proposal-dispatch` GitHub Actions workflow for per-crate crates.io publishing:
   crates: libdd-data-pipeline,libdd-trace-stats,libdd-trace-utils,libdd-ddsketch

## Notable changes since v36.0.0

- `feat(data-pipeline)`: export client-computed span stats as OTLP trace metrics (#2067)
- `feat(otel-thread-ctx)`: add self check capability (#2095)
- `fix(trace-stats)`: add `grpc_method` to aggregation key (#2151)
- `feat(data-pipeline)`: add stdout log trace exporter (#2074)
- `feat(remote-config)`: use the proto file from the agent (#2165)
- `feat(sidecar)`: expose `default_service_name` for `svc.*` process tags (#2053)
- feat(otlp)!: Export OTLP spans with attribute-level OTel compatibility (#2091)

Co-authored-by: munir.abdinur <munir.abdinur@datadoghq.com>
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