fix(pipeline): set OTLP instrumentation scope#173
Conversation
46ff7f9 to
3d3b848
Compare
Overall package sizeSelf size: 30.15 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------|🤖 This report was automatically generated by heaviest-objects-in-the-universe |
33f6770 to
5cf72da
Compare
Update the temporary libdatadog dependency to the PR head ported onto main. Current libdatadog also changed the stats concentrator API, so adapt the WASM stats wrapper to pass the new cardinality limit argument and encode unobfuscated buckets from FlushResult.
5cf72da to
61a7628
Compare
# 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
Co-authored-by: bryan.english <bryan.english@datadoghq.com>
| let buckets = self.concentrator.flush(now(), force); | ||
| if buckets.is_empty() { | ||
| let mut flush = self.concentrator.flush(now(), force); | ||
| if !flush.obfuscated_buckets.is_empty() { |
There was a problem hiding this comment.
This will eventually cause issues when we do turn obfuscation on. Perhaps add a TODO comment along the lines of "stats-obfuscation is currently disabled. Obfuscated stats require the datadog-obfuscation-version header, which prepare_request doesn't emit yet. Implement that before enabling the feature"
| @@ -86,12 +87,19 @@ impl StatsCollector { | |||
| /// release the collector *before* the async send — leaving it available for | |||
| /// `add_spans` while the stats request is in flight. | |||
| pub fn prepare_request(&mut self, force: bool) -> Result<Option<http::Request<Bytes>>, String> { | |||
There was a problem hiding this comment.
shouldn't this also emit collapsed_spans when > 0?
ekump
left a comment
There was a problem hiding this comment.
approving for the OTLP instrumentation scope part. But I don't think we're correctly handling cardinality limits yet. We'll need to sort that out before deploying to customers.
What
Sets the native OTLP instrumentation scope for pipeline trace exports.
The pipeline builder now passes
dd-trace-jsand the tracer version into libdatadog’s OTLP scope metadata. The OTLP HTTP test asserts the emitted JSON payload contains bothscope.nameandscope.version.This also updates the temporary libdatadog git dependency to the amended DataDog/libdatadog#2235 head (
8cd68ab922fb7aade0f089ccfc91291d874673af) and adapts the WASM stats wrapper to libdd-trace-stats 6.0.0’sFlushResultAPI.The stats flush wrapper now returns
{ sent, collapsedSpans }, carryingFlushResult.collapsed_spansthrough the WASM boundary so downstream JS can emit the same collapsed-span health metric as libdd-trace-stats’ native exporter.Why
dd-trace-jsPlatform OTLP trace coverage expects traces to carry the tracer instrumentation scope. With@datadog/libdatadog@0.16.0, native OTLP trace export sendsscope: {}, so the downstream integration test fails before validating spans.Notes
This branch pins exact libdatadog commit
8cd68ab922fb7aade0f089ccfc91291d874673af, which is the head of DataDog/libdatadog#2235 (bengl/otlp-scope-metadata-v37). That upstream PR has been ported onto current libdatadogmainand is mergeable. Once libdatadog publishes an official release/tag containing the fix, this dependency should be replaced with that release/tag before making this PR ready.The collapsed-stats regression uses 15,000 spans to stay comfortably above libdd-trace-stats’ 7,000-entry per-bucket cardinality cap. A smaller 7,100-span margin passed locally and on CentOS Node 20 but failed on CentOS Node 24 with
collapsedSpans === 0.Cargo.lockand rerun downstream verification.Verification
Upstream libdatadog#2235:
cargo +nightly-2026-02-08 fmt --all -- --checkcargo 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-utilscargo check -p libdd-data-pipelinecargo check -p libdd-data-pipeline-fficargo test -p libdd-data-pipeline-ffi trace_exporter --lib(28 pass)LibdatadogReviewFeedbackFixapproved with no findingsThis PR:
cargo build -p pipeline --target wasm32-unknown-unknownnode scripts/build-wasm.js pipelinecargo fmt --check -p pipelinenpm exec -- eslint test/pipeline.jsnode --test test/pipeline.js(51 pass, 0 fail)node --test test/pipeline.js --test-name-pattern 'exports via OTLP HTTP after setOtlpEndpoint'(50 pass, 0 fail)node --test test/pipeline.js --test-name-pattern 'returns collapsed span count'(51 pass, 0 fail)NodeRepinReviewapproved with no findingsPrePushReviewreturned no blockers; only noted acceptable rustfmt reflow incrates/pipeline/src/lib.rsOverflowMarginReviewreturnedSAFE TO PUSHfor the 15,000-span CI fixnode /tmp/ddjs-otlp-scope-check.jsemitted{"name":"dd-trace-js","version":"7.0.0-pre"}and exited 0