Skip to content

feat(otlp): add instrumentation scope metadata#2235

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
bengl/otlp-scope-metadata-v37
Jul 14, 2026
Merged

feat(otlp): add instrumentation scope metadata#2235
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
bengl/otlp-scope-metadata-v37

Conversation

@bengl

@bengl bengl commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds OTLP instrumentation scope metadata to the current trace exporter path.

The trace mapper now copies instrumentation_scope_name and instrumentation_scope_version from OtlpResourceInfo into ScopeSpans.scope. TraceExporterBuilder gets a setter for OTLP trace scope metadata, stores those values in OtlpTraceConfig, and the exporter copies them into each OTLP trace OtlpResourceInfo before mapping.

The C FFI exporter config also exposes the same scope setter so non-Rust tracer callers can configure the scope when they enable OTLP export.

Motivation

dd-trace-js native OTLP trace export emitted scope: {} through @datadog/libdatadog@0.16.0. Its Platform OTLP integration test expects the Datadog tracer scope (name: dd-trace-js) and a tracer version.

Additional Notes

This branch was ported from the old v37-based patch onto current main; it is one commit ahead of main and no longer carries the release-line diff that made the earlier draft conflicting.

DataDog/libdatadog-nodejs#173 currently pins this PR head (8cd68ab922fb7aade0f089ccfc91291d874673af) only as a temporary unreleased dependency. Once libdatadog publishes an official release/tag containing this change, libdatadog-nodejs should move to that release/tag.

How to test the change?

  • cargo +nightly-2026-02-08 fmt --all -- --check
  • cargo test -p libdd-trace-utils otlp_encoder::mapper --lib (26 pass)
  • cargo test -p libdd-data-pipeline trace_exporter::builder::tests::test_new --lib (1 pass)
  • cargo test -p libdd-data-pipeline-ffi config_otlp_instrumentation_scope_test --lib (2 pass)
  • cargo check -p libdd-trace-utils
  • cargo check -p libdd-data-pipeline
  • cargo check -p libdd-data-pipeline-ffi
  • cargo test -p libdd-data-pipeline-ffi trace_exporter --lib (28 pass)
  • Reviewer: LibdatadogReviewFeedbackFix approved with no findings

@datadog-official

datadog-official Bot commented Jul 14, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 81.44%
Overall Coverage: 74.44% (+0.01%)

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

@pr-commenter

pr-commenter Bot commented Jul 14, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-07-14 17:55:18

Comparing candidate commit 8cd68ab in PR branch bengl/otlp-scope-metadata-v37 with baseline commit 56dab85 in branch main.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 138 metrics, 0 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:tags/replace_trace_tags

  • 🟩 execution_time [-120.091ns; -100.555ns] or [-4.818%; -4.034%]

Benchmark execution time: 2026-07-14 17:53:43

Comparing candidate commit 8cd68ab in PR branch bengl/otlp-scope-metadata-v37 with baseline commit 56dab85 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 75 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 ----------------------------------'

Candidate

Omitted due to size.

Baseline

Omitted due to size.

@dd-octo-sts

dd-octo-sts Bot commented Jul 14, 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.a 86.15 MB 86.16 MB +.01% (+13.27 KB) 🔍
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.88 MB 7.88 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 97.40 MB 97.41 MB +.01% (+15.86 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.62 MB 10.62 MB +0% (+288 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.54 MB 25.55 MB +.02% (+6.50 KB) 🔍
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 88.44 KB 88.85 KB +.46% (+424 B) 🔍
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 185.33 MB 185.33 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 957.25 MB 957.28 MB +0% (+26.53 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.35 MB 8.36 MB +.07% (+6.00 KB) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 88.44 KB 88.85 KB +.46% (+424 B) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.72 MB 24.73 MB +.03% (+8.00 KB) 🔍
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.21 MB 49.23 MB +.03% (+16.84 KB) 🔍
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.19 MB 22.20 MB +.02% (+5.50 KB) 🔍
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.82 KB 90.24 KB +.46% (+430 B) 🔍
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 189.78 MB 189.78 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 945.93 MB 945.96 MB +0% (+24.15 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.46 MB 6.46 MB +.03% (+2.50 KB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.82 KB 90.24 KB +.46% (+430 B) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.54 MB 26.55 MB +.02% (+8.00 KB) 🔍
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.82 MB 46.84 MB +.02% (+13.99 KB) 🔍
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 76.96 MB 76.98 MB +.01% (+15.37 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.81 MB 8.81 MB +.04% (+4.00 KB) 🔍
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 92.37 MB 92.39 MB +.01% (+15.78 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.72 MB 10.72 MB +.03% (+4.17 KB) 🔍

@bengl bengl marked this pull request as ready for review July 14, 2026 16:51
@bengl bengl requested review from a team as code owners July 14, 2026 16:51
@bengl bengl requested review from mabdinur and removed request for a team July 14, 2026 16:51

@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: 76a2c25992

ℹ️ 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-data-pipeline/src/trace_exporter/builder.rs
language_version: String,
language_interpreter: String,
language_interpreter_vendor: String,
instrumentation_scope_name: String,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you add test coverage for the new fields in the builder? You can probably just add them to test_new()

Comment thread libdd-data-pipeline/src/trace_exporter/builder.rs
Comment on lines +272 to +273
otlp_instrumentation_scope_name: String,
otlp_instrumentation_scope_version: String,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These fields should live within otlp_config

Previously, OTLP trace export always emitted an empty instrumentation scope. Allow tracers to provide scope name and version through OTLP trace configuration, map those values into ScopeSpans, and expose the same configuration through the C FFI exporter.
@bengl bengl force-pushed the bengl/otlp-scope-metadata-v37 branch from 76a2c25 to 8cd68ab Compare July 14, 2026 17:25
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.

2 participants