Skip to content

feat(profiling): Export OTEL Thread Context API - #2181

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
gleocadie/expose-otel-thread-ctx-ffi-in-artifact
Jul 16, 2026
Merged

feat(profiling): Export OTEL Thread Context API#2181
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
gleocadie/expose-otel-thread-ctx-ffi-in-artifact

Conversation

@gleocadie

Copy link
Copy Markdown
Contributor

What does this PR do?

Export OTEL Thread Context APIs.

Motivation

To be used by downstream libraries

Additional Notes

Anything else we should know when reviewing?

How to test the change?

Describe here in detail how the change can be validated.

@gleocadie
gleocadie requested review from a team as code owners June 30, 2026 08:40
@gleocadie
gleocadie requested a review from ivoanjo June 30, 2026 08:41
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 74.75% (+0.01%)

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

@gleocadie
gleocadie force-pushed the gleocadie/expose-otel-thread-ctx-ffi-in-artifact branch from acfa4fc to 901731b Compare June 30, 2026 08:45

@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: acfa4fca61

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread builder/Cargo.toml
@dd-octo-sts

dd-octo-sts Bot commented Jun 30, 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.88 MB 7.88 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 86.33 MB 86.33 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.62 MB 10.62 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 97.54 MB 97.54 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.58 MB 25.58 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 185.48 MB 185.48 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 958.37 MB 958.37 MB +0% (+3.74 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.37 MB 8.37 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.76 MB 24.76 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.28 MB 49.28 MB +0% (+24 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.23 MB 22.23 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 189.95 MB 189.95 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 946.26 MB 946.26 MB +0% (+3.74 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.47 MB 6.47 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.59 MB 26.59 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.90 MB 46.90 MB +0% (+24 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 77.08 MB 77.08 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.83 MB 8.83 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 92.50 MB 92.50 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.74 MB 10.74 MB 0% (0 B) 👌

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

This looks reasonable BUT I'm not very familiar with our whole export setup so hopefully @morrisonlevi or @danielsn could do a quick pass here maybe?

Comment thread builder/Cargo.toml

@gyuheon0h gyuheon0h left a comment

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.

Seems reasonable!

Copilot AI 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.

Pull request overview

This PR exposes the existing libdd-otel-thread-ctx-ffi C/Rust FFI surface through the libdd-profiling-ffi umbrella crate, and wires the builder packaging flow so the corresponding header can be included in profiling artifacts when enabled.

Changes:

  • Re-export libdd_otel_thread_ctx_ffi::* from libdd-profiling-ffi behind a new otel-thread-ctx-ffi feature.
  • Extend libdd-profiling-ffi feature/dependency plumbing so cbindgen can generate the OTEL thread context header when the optional dependency is enabled.
  • Add a builder feature to optionally include otel-thread-ctx.h and enable otel-thread-ctx-ffi during the profiling build.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libdd-profiling-ffi/src/lib.rs Re-exports the OTEL thread context FFI API behind a feature flag.
libdd-profiling-ffi/Cargo.toml Adds optional dependency + feature wiring, including cbindgen propagation.
Cargo.lock Records the new workspace dependency edge for libdd-profiling-ffi.
builder/src/profiling.rs Optionally installs otel-thread-ctx.h and enables the corresponding profiling-ffi feature during builds.
builder/Cargo.toml Introduces the otel-thread-ctx builder feature toggle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gleocadie
gleocadie force-pushed the gleocadie/expose-otel-thread-ctx-ffi-in-artifact branch from 901731b to 51eefdb Compare July 15, 2026 14:25
@pr-commenter

pr-commenter Bot commented Jul 15, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-07-16 12:06:41

Comparing candidate commit 364b79f in PR branch gleocadie/expose-otel-thread-ctx-ffi-in-artifact with baseline commit 55f3b54 in branch main.

Found 3 performance improvements and 4 performance regressions! Performance is the same for 170 metrics, 10 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:alloc_free/sampled_system_slow_path/4096

  • 🟥 execution_time [+9.056ns; +9.154ns] or [+6.136%; +6.203%]

scenario:datadog_sample_span/name_pattern_rule_not_matching/wall_time

  • 🟥 execution_time [+27.986ns; +28.134ns] or [+17.389%; +17.481%]

scenario:glob_matcher/ascii_wildcard_backtrack_match/wall_time

  • 🟩 execution_time [-4.891ns; -4.873ns] or [-11.735%; -11.692%]

scenario:glob_matcher/ascii_wildcard_question_match/wall_time

  • 🟩 execution_time [-23.166ns; -23.142ns] or [-38.622%; -38.582%]

scenario:glob_matcher/ascii_wildcard_star_match/wall_time

  • 🟩 execution_time [-21.440ns; -21.412ns] or [-36.820%; -36.772%]

scenario:receiver_entry_point/report/2644

  • 🟥 execution_time [+204.377µs; +213.294µs] or [+5.701%; +5.950%]

scenario:tags/replace_trace_tags

  • 🟥 execution_time [+206.803ns; +222.009ns] or [+8.724%; +9.366%]

Candidate

Omitted due to size.

Baseline

Omitted due to size.

Comment thread builder/Cargo.toml Outdated
Comment thread builder/src/profiling.rs Outdated
@gleocadie
gleocadie force-pushed the gleocadie/expose-otel-thread-ctx-ffi-in-artifact branch 2 times, most recently from 8073c90 to ad5d657 Compare July 16, 2026 09:04
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Jul 16, 2026
…#2243)

# What does this PR do?

Hides sanity check symbols behind a symbol which is defined if `sanity-check` feature is enabled.

# Motivation

While reviewing #2181 I noticed that the sanity check symbol was included in the header unconditionally.



Co-authored-by: julio.gonzalez <julio.gonzalez@datadoghq.com>
@gleocadie
gleocadie force-pushed the gleocadie/expose-otel-thread-ctx-ffi-in-artifact branch from ad5d657 to 364b79f Compare July 16, 2026 11:19
@gleocadie

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 13:00:03 UTC ℹ️ Start processing command /merge


2026-07-16 13:00:08 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-16 13:38:18 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 4a914bb into main Jul 16, 2026
91 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the gleocadie/expose-otel-thread-ctx-ffi-in-artifact branch July 16, 2026 13:38
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.

7 participants