Skip to content

feat(span): internal API split for Span#7881

Open
pabloerhard wants to merge 32 commits intomasterfrom
pabloerhard/public-span-wrapper
Open

feat(span): internal API split for Span#7881
pabloerhard wants to merge 32 commits intomasterfrom
pabloerhard/public-span-wrapper

Conversation

@pabloerhard
Copy link
Copy Markdown
Contributor

@pabloerhard pabloerhard commented Mar 29, 2026

What does this PR do?

This PR adds an internal API split for Span which allows a distinction between the internal use of Span and the user use of Span. This internal API split consists of adding a wrapper to the user exposed Span through the proxy.

This PR adds the wrapper on the proxy exposed startSpand, the internal trace which is mostly user used and the internal scope.

Motivation

Having a distinction between internal and external use of Span, and acting accoridngly.

Additional Notes

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.84%. Comparing base (abc727b) to head (d8be3e0).

Files with missing lines Patch % Lines
packages/dd-trace/src/llmobs/sdk.js 80.00% 1 Missing ⚠️
packages/dd-trace/src/noop/proxy.js 88.88% 1 Missing ⚠️
packages/dd-trace/src/opentracing/public/span.js 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7881      +/-   ##
==========================================
+ Coverage   73.82%   73.84%   +0.02%     
==========================================
  Files         773      774       +1     
  Lines       35972    36020      +48     
==========================================
+ Hits        26556    26600      +44     
- Misses       9416     9420       +4     
Flag Coverage Δ
aiguard-macos 36.57% <67.27%> (+0.05%) ⬆️
aiguard-ubuntu 36.67% <67.27%> (+0.05%) ⬆️
aiguard-windows 36.47% <67.27%> (+0.05%) ⬆️
apm-capabilities-tracing-macos 48.49% <87.71%> (+0.11%) ⬆️
apm-capabilities-tracing-ubuntu 48.53% <87.71%> (+0.07%) ⬆️
apm-capabilities-tracing-windows 48.31% <87.71%> (+0.08%) ⬆️
apm-integrations-child-process 36.17% <57.40%> (+0.01%) ⬆️
apm-integrations-couchbase-18 35.07% <53.70%> (-0.01%) ⬇️
apm-integrations-couchbase-eol 35.15% <53.70%> (+0.02%) ⬆️
apm-integrations-oracledb 35.11% <53.70%> (-0.01%) ⬇️
appsec-express 52.73% <37.03%> (-0.13%) ⬇️
appsec-fastify 49.23% <37.03%> (-0.11%) ⬇️
appsec-graphql 49.50% <37.03%> (-0.10%) ⬇️
appsec-kafka 42.07% <37.03%> (-0.11%) ⬇️
appsec-ldapjs 41.37% <33.33%> (-0.09%) ⬇️
appsec-lodash 41.40% <33.33%> (-0.09%) ⬇️
appsec-macos 56.80% <75.92%> (-0.01%) ⬇️
appsec-mongodb-core 46.00% <37.03%> (-0.10%) ⬇️
appsec-mongoose 46.57% <37.03%> (-0.10%) ⬇️
appsec-mysql 48.70% <37.03%> (-0.11%) ⬇️
appsec-node-serialize 40.58% <33.33%> (-0.09%) ⬇️
appsec-passport 44.53% <37.03%> (-0.11%) ⬇️
appsec-postgres 48.28% <37.03%> (-0.20%) ⬇️
appsec-sourcing 40.03% <33.33%> (-0.10%) ⬇️
appsec-stripe 42.29% <33.33%> (-0.10%) ⬇️
appsec-template 40.74% <33.33%> (-0.09%) ⬇️
appsec-ubuntu 56.87% <75.92%> (-0.01%) ⬇️
appsec-windows 56.69% <75.92%> (+0.01%) ⬆️
instrumentations-instrumentation-bluebird 29.81% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-body-parser 37.63% <31.48%> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 35.43% <29.62%> (-0.11%) ⬇️
instrumentations-instrumentation-cookie-parser 31.74% <29.62%> (-0.08%) ⬇️
instrumentations-instrumentation-express 31.96% <29.62%> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.86% <29.62%> (-0.08%) ⬇️
instrumentations-instrumentation-express-session 37.27% <29.62%> (-0.10%) ⬇️
instrumentations-instrumentation-fs 29.48% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-generic-pool 31.12% <ø> (ø)
instrumentations-instrumentation-http 36.87% <31.48%> (-0.10%) ⬇️
instrumentations-instrumentation-knex 29.78% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-mongoose 30.89% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-multer 37.41% <31.48%> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 35.38% <29.62%> (-0.10%) ⬇️
instrumentations-instrumentation-passport 41.15% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-passport-http 40.85% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 41.34% <33.33%> (-0.10%) ⬇️
instrumentations-instrumentation-pg 34.90% <29.62%> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.74% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-promise-js 29.75% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-q 29.78% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-url 29.74% <29.62%> (-0.07%) ⬇️
instrumentations-instrumentation-when 29.76% <29.62%> (-0.07%) ⬇️
llmobs-ai 38.37% <31.48%> (-0.10%) ⬇️
llmobs-anthropic 37.83% <29.62%> (-0.10%) ⬇️
llmobs-bedrock 37.10% <29.62%> (-0.09%) ⬇️
llmobs-google-genai 37.52% <29.62%> (-0.09%) ⬇️
llmobs-langchain 37.09% <64.81%> (-0.08%) ⬇️
llmobs-openai 41.32% <62.96%> (+0.01%) ⬆️
llmobs-vertex-ai 37.69% <29.62%> (-0.10%) ⬇️
platform-core 31.10% <ø> (ø)
platform-esbuild 33.97% <ø> (ø)
platform-instrumentations-misc 40.97% <ø> (ø)
platform-shimmer 37.00% <ø> (ø)
platform-unit-guardrails 32.49% <ø> (ø)
platform-webpack 20.85% <30.61%> (+0.03%) ⬆️
plugins-azure-durable-functions 25.87% <ø> (ø)
plugins-azure-event-hubs 26.03% <ø> (ø)
plugins-azure-service-bus 25.40% <ø> (ø)
plugins-bullmq 40.70% <33.33%> (+0.01%) ⬆️
plugins-cassandra 35.25% <53.70%> (-0.01%) ⬇️
plugins-cookie 27.06% <ø> (ø)
plugins-cookie-parser 26.85% <ø> (ø)
plugins-crypto 26.55% <ø> (ø)
plugins-dd-trace-api 35.56% <64.81%> (+0.05%) ⬆️
plugins-express-mongo-sanitize 26.99% <ø> (ø)
plugins-express-session 26.81% <ø> (ø)
plugins-fastify 39.40% <46.29%> (-0.04%) ⬇️
plugins-fetch 35.71% <31.48%> (-0.09%) ⬇️
plugins-fs 35.77% <57.40%> (+0.01%) ⬆️
plugins-generic-pool 25.92% <ø> (ø)
plugins-google-cloud-pubsub 43.06% <51.85%> (-0.04%) ⬇️
plugins-grpc 38.11% <59.25%> (+<0.01%) ⬆️
plugins-handlebars 27.03% <ø> (ø)
plugins-hapi 37.28% <46.29%> (-0.04%) ⬇️
plugins-hono 37.55% <46.29%> (-0.04%) ⬇️
plugins-ioredis 35.69% <53.70%> (-0.01%) ⬇️
plugins-knex 26.67% <ø> (ø)
plugins-langgraph 35.05% <29.62%> (-0.09%) ⬇️
plugins-ldapjs 24.45% <ø> (ø)
plugins-light-my-request 26.41% <ø> (ø)
plugins-limitd-client 30.02% <29.62%> (-0.08%) ⬇️
plugins-lodash 26.00% <ø> (ø)
plugins-mariadb 36.66% <66.66%> (+0.08%) ⬆️
plugins-memcached 35.35% <53.70%> (-0.01%) ⬇️
plugins-microgateway-core 36.38% <46.29%> (-0.03%) ⬇️
plugins-moleculer 38.02% <33.33%> (-0.10%) ⬇️
plugins-mongodb 36.46% <55.55%> (+<0.01%) ⬆️
plugins-mongodb-core 36.08% <33.33%> (-0.09%) ⬇️
plugins-mongoose 36.09% <53.70%> (-0.01%) ⬇️
plugins-multer 26.81% <ø> (ø)
plugins-mysql 36.48% <66.66%> (+0.04%) ⬆️
plugins-mysql2 36.46% <66.66%> (+0.04%) ⬆️
plugins-node-serialize 27.10% <ø> (ø)
plugins-opensearch 35.01% <51.85%> (-0.01%) ⬇️
plugins-passport-http 26.85% <ø> (ø)
plugins-postgres 34.40% <53.70%> (+<0.01%) ⬆️
plugins-process 26.55% <ø> (ø)
plugins-pug 27.06% <ø> (ø)
plugins-redis 35.92% <51.85%> (+0.01%) ⬆️
plugins-router 39.96% <33.33%> (-0.11%) ⬇️
plugins-sequelize 25.68% <ø> (ø)
plugins-test-and-upstream-amqp10 35.70% <46.29%> (-0.03%) ⬇️
plugins-test-and-upstream-amqplib 40.89% <51.85%> (-0.04%) ⬇️
plugins-test-and-upstream-apollo 36.50% <31.48%> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 35.67% <66.66%> (+0.06%) ⬆️
plugins-test-and-upstream-bunyan 31.27% <51.85%> (+0.01%) ⬆️
plugins-test-and-upstream-connect 37.90% <50.00%> (-0.03%) ⬇️
plugins-test-and-upstream-graphql 37.27% <57.40%> (+<0.01%) ⬆️
plugins-test-and-upstream-koa 37.51% <50.00%> (-0.02%) ⬇️
plugins-test-and-upstream-protobufjs 35.89% <66.66%> (+0.06%) ⬆️
plugins-test-and-upstream-rhea 41.01% <62.96%> (+<0.01%) ⬆️
plugins-undici 36.51% <33.33%> (-0.09%) ⬇️
plugins-url 26.55% <ø> (ø)
plugins-valkey 35.38% <53.70%> (-0.01%) ⬇️
plugins-vm 26.55% <ø> (ø)
plugins-winston 31.57% <51.85%> (-0.12%) ⬇️
plugins-ws 39.02% <62.96%> (+0.01%) ⬆️
profiling-macos 37.92% <29.62%> (-0.56%) ⬇️
profiling-ubuntu 38.09% <29.62%> (-0.10%) ⬇️
profiling-windows 39.45% <29.62%> (-0.10%) ⬇️
serverless-azure-functions-client 25.75% <ø> (ø)
serverless-azure-functions-eventhubs 25.75% <ø> (ø)
serverless-azure-functions-servicebus 25.75% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 29, 2026

Overall package size

Self size: 5.48 MB
Deduped: 6.32 MB
No deduping: 6.32 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

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

@datadog-prod-us1-5
Copy link
Copy Markdown

datadog-prod-us1-5 bot commented Mar 29, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 89.66%
Overall Coverage: 68.26% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: d8be3e0 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 29, 2026

Benchmarks

Benchmark execution time: 2026-04-10 02:39:40

Comparing candidate commit d8be3e0 in PR branch pabloerhard/public-span-wrapper with baseline commit abc727b in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 229 metrics, 31 unstable metrics.

testName,
testStatus,
finishTime: this.activeTestSpan._getTime(), // we store the finish time here
finishTime: activeSpan._getTime(), // we store the finish time here
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.

What should be on the store is an internal span, not a public span, so this change shouldn't be needed.

Copy link
Copy Markdown
Contributor Author

@pabloerhard pabloerhard Apr 8, 2026

Choose a reason for hiding this comment

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

This does not come from the store, it uses the tracer to start a span which then returns a wrapped a span.

@pabloerhard pabloerhard requested a review from rochdev March 31, 2026 00:56
@pabloerhard pabloerhard changed the title feat(span): internal API split for Span and Scope feat(span): internal API split for Span Mar 31, 2026
@pabloerhard pabloerhard marked this pull request as ready for review April 7, 2026 14:24
@pabloerhard pabloerhard requested review from a team as code owners April 7, 2026 14:24
@pabloerhard pabloerhard requested review from ida613 and removed request for a team April 7, 2026 14:24
ERROR_STACK: 'error.stack',
IGNORE_OTEL_ERROR: Symbol('ignore.otel.error'),
COMPONENT: 'component',
SVC_SRC_KEY: '_dd.svc_src',
Copy link
Copy Markdown
Contributor Author

@pabloerhard pabloerhard Apr 7, 2026

Choose a reason for hiding this comment

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

This file change will not be needed once #7824 is merged.
This should be resolved depending on what PR gets merged first.

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