Skip to content

fix(opentelemetry): apply global/resource tags to OTel-bridged spans#9229

Merged
jessicagamio merged 1 commit into
masterfrom
MLOS-758-otel-bridge-global-tags
Jul 7, 2026
Merged

fix(opentelemetry): apply global/resource tags to OTel-bridged spans#9229
jessicagamio merged 1 commit into
masterfrom
MLOS-758-otel-bridge-global-tags

Conversation

@jessicagamio

Copy link
Copy Markdown
Contributor

What does this PR do?

Applies global/resource tags (DD_TAGS, OTEL_RESOURCE_ATTRIBUTES) to spans created through the OpenTelemetry API bridge (DD_TRACE_OTEL_ENABLED=true).

Motivation

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags, but they were only applied to spans created via the native tracer (opentracing/tracer.jsspan.addTags(this._config.tags)). Spans created through the OTel API bridge (opentelemetry/span.js) were constructed directly with only service/resource/span.kind, so global/resource tags never reached them.

As a result, documented opt-outs that rely on a resource attribute reaching the span — e.g. OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false — had no effect on OTel-bridged spans, even though the value was correctly present in the tracer config.

Change

Seed the bridge span's tags with config.tags as defaults, keeping the explicit service/resource/span.kind and any user-set OTel attributes as overrides — matching the precedence of the native path.

Testing

Added unit tests in packages/dd-trace/test/opentelemetry/span.spec.js:

  • global config tags (DD_TAGS / OTEL_RESOURCE_ATTRIBUTES) are applied to bridged spans (fails without this change)
  • explicit span attributes take precedence over global config tags
  • reserved service.name/resource.name/span.kind win over colliding config tags (fails if the spread order is reversed)

The full packages/dd-trace/test/opentelemetry/ suite passes.

Internal reference: MLOB-7714

🤖 Generated with Claude Code

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags but were
only applied to spans created via the native tracer (opentracing/tracer.js).
Spans created through the OTel API bridge were built directly with only
service/resource/span.kind, so global/resource tags never reached them —
documented opt-outs like OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false
had no effect on OTel-bridged spans.

Seed the bridge span's tags with config.tags as defaults, keeping explicit
service/resource/span.kind and user-set attributes as overrides, matching
the native path's precedence.
@jessicagamio
jessicagamio requested a review from a team as a code owner July 7, 2026 00:32
@jessicagamio
jessicagamio requested review from BridgeAR and removed request for a team July 7, 2026 00:32
@dd-octo-sts

dd-octo-sts Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.56 MB
Deduped: 7.21 MB
No deduping: 7.21 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.0 | 117.14 kB | 432.47 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jul 7, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 87.78% (+0.07%)

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

@pr-commenter

pr-commenter Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-07 00:46:34

Comparing candidate commit 2315268 in PR branch MLOS-758-otel-bridge-global-tags with baseline commit f3dba8a in branch master.

📊 Benchmarking dashboard

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

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-180.240ms; +185.248ms] or [-6.817%; +7.007%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-207.478ms; +199.311ms] or [-8.231%; +7.907%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-155.778ms; +158.920ms] or [-5.415%; +5.524%]

scenario:appsec-control-20

  • unstable execution_time [-110.047ms; +116.617ms] or [-6.781%; +7.186%]

scenario:appsec-control-24

  • unstable execution_time [-103.655ms; +105.821ms] or [-8.539%; +8.717%]

scenario:appsec-control-26

  • unstable execution_time [-112727.984µs; +112384.217µs] or [-9.368%; +9.339%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-25.995ms; +32.530ms] or [-4.721%; +5.908%]

scenario:debugger-line-probe-with-snapshot-default-24

  • unstable cpu_user_time [-285.835ms; +537.560ms] or [-3.583%; +6.738%]
  • unstable instructions [-2.2G instructions; +4.6G instructions] or [-3.446%; +7.125%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-2858.600ms; +1807.375ms] or [-30.176%; +19.079%]
  • unstable execution_time [-2876.113ms; +1829.011ms] or [-28.321%; +18.010%]
  • unstable instructions [-24.1G instructions; +15.3G instructions] or [-31.020%; +19.658%]
  • unstable max_rss_usage [-11.373MB; +6.899MB] or [-7.089%; +4.300%]
  • unstable throughput [-509.559op/s; +810.093op/s] or [-15.500%; +24.642%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1463.995ms; +966.954ms] or [-17.645%; +11.654%]
  • unstable execution_time [-1481.743ms; +975.840ms] or [-16.510%; +10.873%]
  • unstable instructions [-12.2G instructions; +8.1G instructions] or [-18.082%; +11.896%]
  • unstable throughput [-373.413op/s; +398.751op/s] or [-10.152%; +10.841%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-2084.617ms; +3379.921ms] or [-22.360%; +36.254%]
  • unstable execution_time [-2065.632ms; +3352.096ms] or [-20.615%; +33.454%]
  • unstable instructions [-18.5G instructions; +30.0G instructions] or [-23.859%; +38.774%]
  • unstable max_rss_usage [-7.685MB; +10.278MB] or [-4.828%; +6.457%]
  • unstable throughput [-744.793op/s; +452.594op/s] or [-22.703%; +13.796%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-445.270ms; +276.301ms] or [-8.976%; +5.570%]
  • unstable execution_time [-445.970ms; +275.503ms] or [-8.859%; +5.473%]
  • unstable throughput [-93417.773op/s; +155067.859op/s] or [-5.602%; +9.299%]

scenario:plugin-graphql-long-with-depth-and-collapse-off-20

  • unstable max_rss_usage [-19.462MB; +33.295MB] or [-5.195%; +8.888%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable max_rss_usage [-8573.375KB; +10174.175KB] or [-4.593%; +5.450%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4912.285KB; +3303.285KB] or [-6.187%; +4.161%]

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.61%. Comparing base (f3dba8a) to head (2315268).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9229      +/-   ##
==========================================
+ Coverage   93.56%   93.61%   +0.05%     
==========================================
  Files         900      900              
  Lines       52690    52690              
  Branches    12411    12411              
==========================================
+ Hits        49299    49328      +29     
+ Misses       3391     3362      -29     
Flag Coverage Δ
aiguard 34.97% <ø> (-0.08%) ⬇️
aiguard-integration 41.96% <ø> (+<0.01%) ⬆️
apm-bucket-0 34.89% <ø> (+0.02%) ⬆️
apm-bucket-1 40.49% <ø> (-0.16%) ⬇️
apm-bucket-2 37.48% <ø> (+0.20%) ⬆️
apm-capabilities-tracing 48.94% <ø> (ø)
apm-integrations-aerospike 33.11% <ø> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript 40.01% <ø> (-0.17%) ⬇️
apm-integrations-couchbase 33.23% <ø> (-0.24%) ⬇️
apm-integrations-http 42.04% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs 40.25% <ø> (-0.08%) ⬇️
apm-integrations-next 29.58% <ø> (-0.11%) ⬇️
apm-integrations-prisma 35.17% <ø> (-0.07%) ⬇️
apm-integrations-tedious 34.03% <ø> (?)
appsec 57.80% <ø> (-0.15%) ⬇️
appsec-express_fastify_graphql 53.86% <ø> (-0.05%) ⬇️
appsec-integration 35.60% <ø> (ø)
appsec-kafka_ldapjs_lodash 43.74% <ø> (-0.07%) ⬇️
appsec-mongodb-core_mongoose_mysql 48.88% <ø> (-0.06%) ⬇️
appsec-next 28.04% <ø> (-0.07%) ⬇️
appsec-node-serialize_passport_postgres 47.95% <ø> (-0.18%) ⬇️
appsec-sourcing_stripe_template 45.62% <ø> (-0.06%) ⬇️
debugger 44.65% <ø> (+0.04%) ⬆️
instrumentations-bucket-0 28.15% <ø> (-0.08%) ⬇️
instrumentations-bucket-1 37.59% <ø> (-0.07%) ⬇️
instrumentations-bucket-10 40.50% <ø> (-0.07%) ⬇️
instrumentations-bucket-11 27.95% <ø> (-0.08%) ⬇️
instrumentations-bucket-12 28.78% <ø> (-0.08%) ⬇️
instrumentations-bucket-13 27.78% <ø> (-0.08%) ⬇️
instrumentations-bucket-2 30.35% <ø> (-0.08%) ⬇️
instrumentations-bucket-3 36.05% <ø> (-0.07%) ⬇️
instrumentations-bucket-4 28.59% <ø> (-0.08%) ⬇️
instrumentations-bucket-5 36.41% <ø> (-0.07%) ⬇️
instrumentations-bucket-6 38.41% <ø> (-0.08%) ⬇️
instrumentations-bucket-7 36.13% <ø> (-0.07%) ⬇️
instrumentations-bucket-8 37.09% <ø> (-0.07%) ⬇️
instrumentations-bucket-9 39.60% <ø> (-0.07%) ⬇️
instrumentations-instrumentation-couchbase 46.48% <ø> (ø)
instrumentations-integration-esbuild 24.48% <ø> (ø)
llmobs-ai_anthropic_bedrock 39.67% <ø> (-0.07%) ⬇️
llmobs-google-genai_langchain_vertex-ai 36.97% <ø> (-0.06%) ⬇️
llmobs-openai 39.73% <ø> (-0.07%) ⬇️
llmobs-sdk 43.57% <ø> (-0.08%) ⬇️
master-coverage 93.61% <ø> (?)
openfeature 37.92% <ø> (ø)
openfeature-unit 50.47% <ø> (ø)
platform-core_esbuild_instrumentations-misc 22.91% <ø> (ø)
platform-integration 47.56% <ø> (ø)
platform-shimmer_unit-guardrails_webpack 18.43% <ø> (ø)
plugins-bucket-0 36.51% <ø> (-0.07%) ⬇️
plugins-bucket-1 39.76% <ø> (ø)
plugins-bucket-11 38.61% <ø> (-0.08%) ⬇️
plugins-bucket-17 39.20% <ø> (-0.07%) ⬇️
plugins-bucket-18 42.16% <ø> (-0.07%) ⬇️
plugins-bucket-19 39.96% <ø> (-0.07%) ⬇️
plugins-bucket-20 43.42% <ø> (-0.07%) ⬇️
plugins-bucket-4 37.88% <ø> (-0.07%) ⬇️
plugins-bullmq_cassandra_cookie 39.91% <ø> (-0.07%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 33.21% <ø> (-0.08%) ⬇️
plugins-fetch_fs_generic-pool 36.17% <ø> (-0.10%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 43.07% <ø> (-0.08%) ⬇️
plugins-hapi_hono_ioredis 37.93% <ø> (-0.07%) ⬇️
plugins-jest_knex_langgraph 32.60% <ø> (-0.08%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 27.85% <ø> (-0.14%) ⬇️
plugins-lodash_mariadb_memcached 35.16% <ø> (-0.08%) ⬇️
plugins-mongodb_mongodb-core_mongoose 36.46% <ø> (-0.06%) ⬇️
plugins-multer_mysql_mysql2 35.13% <ø> (-0.08%) ⬇️
plugins-nats_node-serialize_opensearch 37.29% <ø> (-0.08%) ⬇️
plugins-passport-http_pino_postgres 35.52% <ø> (-0.08%) ⬇️
plugins-process_pug_redis 34.25% <ø> (-0.08%) ⬇️
plugins-undici_url_valkey 36.01% <ø> (-0.08%) ⬇️
plugins-vm_winston_ws 37.70% <ø> (-0.08%) ⬇️
profiling 43.82% <ø> (-0.07%) ⬇️
serverless-aws-sdk-aws-sdk 33.31% <ø> (-0.07%) ⬇️
serverless-aws-sdk-bedrockruntime 32.18% <ø> (-0.07%) ⬇️
serverless-aws-sdk-client 37.16% <ø> (ø)
serverless-aws-sdk-dynamodb 34.12% <ø> (-0.15%) ⬇️
serverless-aws-sdk-eventbridge 27.35% <ø> (-0.07%) ⬇️
serverless-aws-sdk-kinesis 37.53% <ø> (-0.07%) ⬇️
serverless-aws-sdk-lambda 34.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-s3 32.62% <ø> (-0.07%) ⬇️
serverless-aws-sdk-serverless-peer-service 39.72% <ø> (+0.01%) ⬆️
serverless-aws-sdk-sns 38.39% <ø> (-0.19%) ⬇️
serverless-aws-sdk-sqs 38.13% <ø> (-0.07%) ⬇️
serverless-aws-sdk-stepfunctions 33.21% <ø> (-0.07%) ⬇️
serverless-aws-sdk-util 47.95% <ø> (ø)
serverless-bucket-0 39.62% <ø> (ø)
serverless-lambda 34.32% <ø> (-0.09%) ⬇️
test-optimization-cucumber 52.39% <ø> (+0.11%) ⬆️
test-optimization-cypress 50.04% <ø> (+0.06%) ⬆️
test-optimization-jest 55.60% <ø> (+0.10%) ⬆️
test-optimization-mocha 53.47% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-atr 43.42% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-efd 43.70% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-final-status 43.82% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-impacted-tests 43.25% <ø> (ø)
test-optimization-playwright-playwright-reporting 43.36% <ø> (+0.08%) ⬆️
test-optimization-playwright-playwright-test-management 44.81% <ø> (-0.02%) ⬇️
test-optimization-playwright-playwright-test-span 44.60% <ø> (+0.07%) ⬆️
test-optimization-selenium 45.40% <ø> (+0.06%) ⬆️
test-optimization-testopt 46.73% <ø> (+0.08%) ⬆️
test-optimization-vitest 52.65% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ZStriker19
ZStriker19 self-requested a review July 7, 2026 14:43

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

This looks good to me as a way to meet the need of supporting OTEL_RESOURCE_ATTRIBUTES without overriding the bridge's reserved values. Nice job!

@jessicagamio
jessicagamio merged commit c632401 into master Jul 7, 2026
653 checks passed
@jessicagamio
jessicagamio deleted the MLOS-758-otel-bridge-global-tags branch July 7, 2026 18:57
dd-octo-sts Bot pushed a commit that referenced this pull request Jul 7, 2026
…9229)

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags but were
only applied to spans created via the native tracer (opentracing/tracer.js).
Spans created through the OTel API bridge were built directly with only
service/resource/span.kind, so global/resource tags never reached them —
documented opt-outs like OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false
had no effect on OTel-bridged spans.

Seed the bridge span's tags with config.tags as defaults, keeping explicit
service/resource/span.kind and user-set attributes as overrides, matching
the native path's precedence.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 7, 2026
dd-octo-sts Bot pushed a commit that referenced this pull request Jul 7, 2026
…9229)

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags but were
only applied to spans created via the native tracer (opentracing/tracer.js).
Spans created through the OTel API bridge were built directly with only
service/resource/span.kind, so global/resource tags never reached them —
documented opt-outs like OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false
had no effect on OTel-bridged spans.

Seed the bridge span's tags with config.tags as defaults, keeping explicit
service/resource/span.kind and user-set attributes as overrides, matching
the native path's precedence.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 7, 2026

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

The fix itself will work, I just think we should do it in a way where we do not have to copy these on each span, since that adds a lot of CPU overhead :) I will open a follow-up for that

juan-fernandez pushed a commit that referenced this pull request Jul 8, 2026
…9229)

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags but were
only applied to spans created via the native tracer (opentracing/tracer.js).
Spans created through the OTel API bridge were built directly with only
service/resource/span.kind, so global/resource tags never reached them —
documented opt-outs like OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false
had no effect on OTel-bridged spans.

Seed the bridge span's tags with config.tags as defaults, keeping explicit
service/resource/span.kind and user-set attributes as overrides, matching
the native path's precedence.
juan-fernandez pushed a commit that referenced this pull request Jul 8, 2026
…9229)

OTEL_RESOURCE_ATTRIBUTES and DD_TAGS are parsed into config.tags but were
only applied to spans created via the native tracer (opentracing/tracer.js).
Spans created through the OTel API bridge were built directly with only
service/resource/span.kind, so global/resource tags never reached them —
documented opt-outs like OTEL_RESOURCE_ATTRIBUTES=dd_llmobs_enabled=false
had no effect on OTel-bridged spans.

Seed the bridge span's tags with config.tags as defaults, keeping explicit
service/resource/span.kind and user-set attributes as overrides, matching
the native path's precedence.
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