Skip to content

feat(opentelemetry): Add tracingChannel utility for context propagation - #20358

Merged
logaretm merged 3 commits into
developfrom
awad/tracing-channel-otel-vendoring
Apr 17, 2026
Merged

feat(opentelemetry): Add tracingChannel utility for context propagation#20358
logaretm merged 3 commits into
developfrom
awad/tracing-channel-otel-vendoring

Conversation

@logaretm

@logaretmlogaretm commented Apr 16, 2026

Copy link
Copy Markdown
Member
  • Vendors and adapts otel-tracing-channel into @sentry/opentelemetry
  • Provides a drop-in tracingChannel() wrapper around Node.js TracingChannel that automatically binds OTel context propagation via bindStore
  • Uses our public getAsyncLocalStorageLookup() API to access the ALS instead of relying on OTel private _asyncLocalStorage internals
  • subscribe/unsubscribe accept partial subscriber objects so callers only provide handlers they need

The util is exposed in a subpath export because nextjs does not externalize node:diagnostic_channels and will crash.

@logaretmlogaretm changed the title feat(opentelemetry): Add tracingChannel utility for TracingChannel context propagationfeat(opentelemetry): Add tracingChannel utility for context propagationApr 16, 2026
@github-actions

github-actionsBot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser25.88 kB--
@sentry/browser - with treeshaking flags24.35 kB--
@sentry/browser (incl. Tracing)43.77 kB--
@sentry/browser (incl. Tracing + Span Streaming)45.47 kB--
@sentry/browser (incl. Tracing, Profiling)48.7 kB--
@sentry/browser (incl. Tracing, Replay)82.89 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags72.4 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)87.58 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)99.83 kB--
@sentry/browser (incl. Feedback)42.7 kB--
@sentry/browser (incl. sendFeedback)30.55 kB--
@sentry/browser (incl. FeedbackAsync)35.55 kB--
@sentry/browser (incl. Metrics)27.16 kB--
@sentry/browser (incl. Logs)27.29 kB--
@sentry/browser (incl. Metrics & Logs)27.98 kB--
@sentry/react27.62 kB--
@sentry/react (incl. Tracing)46.01 kB--
@sentry/vue30.7 kB--
@sentry/vue (incl. Tracing)45.58 kB--
@sentry/svelte25.89 kB--
CDN Bundle28.55 kB--
CDN Bundle (incl. Tracing)44.82 kB--
CDN Bundle (incl. Logs, Metrics)29.93 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)45.91 kB--
CDN Bundle (incl. Replay, Logs, Metrics)68.83 kB--
CDN Bundle (incl. Tracing, Replay)81.78 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)82.85 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)87.29 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)88.36 kB--
CDN Bundle - uncompressed83.4 kB--
CDN Bundle (incl. Tracing) - uncompressed134.03 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed87.55 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed137.44 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed210.91 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed251.26 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed254.66 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed264.18 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed267.56 kB--
@sentry/nextjs (client)48.54 kB--
@sentry/sveltekit (client)44.18 kB--
@sentry/node-core57.97 kB+0.01%+5 B 🔺
@sentry/node174.81 kB+0.01%+6 B 🔺
@sentry/node - without tracing97.93 kB+0.03%+24 B 🔺
@sentry/aws-serverless115.16 kB+0.01%+5 B 🔺

View base workflow run

@logaretm
logaretm marked this pull request as ready for review April 16, 2026 16:24

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

Pull request overview

Adds a Node.js-only tracingChannel() utility to @sentry/opentelemetry to enable OpenTelemetry context propagation for node:diagnostics_channel tracing channels, with accompanying packaging and tests.

Changes:

  • Added src/tracingChannel.ts implementing tracingChannel() with ALS-backed context propagation via bindStore.
  • Added a new ./tracingChannel package subpath export and Rollup entrypoint to build it separately from the main bundle.
  • Added Vitest coverage validating active-span behavior, nesting/parenting, and context non-leakage.

Reviewed changes

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

FileDescription
packages/opentelemetry/src/tracingChannel.tsImplements the tracingChannel() wrapper and context binding logic.
packages/opentelemetry/test/tracingChannel.test.tsAdds unit tests for span activation, parent/child relationships, and context isolation.
packages/opentelemetry/rollup.npm.config.mjsBuilds tracingChannel.ts as a separate entrypoint to keep Node-only deps out of the main bundle.
packages/opentelemetry/package.jsonExposes ./tracingChannel subpath with ESM/CJS + types outputs.

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

Comment threadpackages/opentelemetry/test/tracingChannel.test.ts
Comment threadpackages/opentelemetry/src/tracingChannel.ts
Comment threadpackages/opentelemetry/src/tracingChannel.ts
logaretmand others added 2 commits April 16, 2026 13:05
…context propagation
Vendors and adapts the `otel-tracing-channel` package into `@sentry/opentelemetry`,
providing a drop-in wrapper around Node.js `TracingChannel` that automatically binds
OTel context propagation via `bindStore`. Uses our public `getAsyncLocalStorageLookup()`
API to access the ALS instead of relying on OTel private internals.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@logaretm
logaretmforce-pushed the awad/tracing-channel-otel-vendoring branch from f3b037f to 1b87a8fCompareApril 16, 2026 17:05
Comment threadpackages/opentelemetry/src/tracingChannel.ts
Comment threadpackages/opentelemetry/package.json Outdated
logaretm added a commit that referenced this pull request Apr 17, 2026
Implements HTTP server instrumentation for both `h3` and `srvx` by
listening to their tracing channel events.
- `h3` TC PR: h3js/h3#1251
- `srvx` TC PR: h3js/srvx#141Closes#18123 ---
**This PR is part of a stack:**
- #20358
- #19224
- #19225 👈
- #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5973ab5. Configure here.

Comment threadpackages/opentelemetry/test/tracingChannel.test.ts
@logaretm
logaretm merged commit fa9fea2 into developApr 17, 2026
244 checks passed
@logaretm
logaretm deleted the awad/tracing-channel-otel-vendoring branch April 17, 2026 15:50
logaretm added a commit that referenced this pull request Apr 17, 2026
Implements HTTP server instrumentation for both `h3` and `srvx` by
listening to their tracing channel events.
- `h3` TC PR: h3js/h3#1251
- `srvx` TC PR: h3js/srvx#141Closes#18123
---
**This PR is part of a stack:**
- #20358
- #19224
- #19225 👈
- #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 18, 2026
Implements HTTP server instrumentation for both `h3` and `srvx` by
listening to their tracing channel events.
- `h3` TC PR: h3js/h3#1251
- `srvx` TC PR: h3js/srvx#141Closes#18123
---
**This PR is part of a stack:**
- #20358
- #19224
- #19225 👈
- #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 22, 2026
Adds automatic sourcemap handling to the Nitro SDK, using
`@sentry/bundler-plugin-core` for builder-agnostic post-build upload.
Nitro uses rollup or rolldown, so it made sense to make it as agnostic
as possible.
Closes#17992 ---
**This PR is part of a stack:**
- #20358
- #19224
- #19225
- #19304 👈
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 22, 2026
Implements HTTP server instrumentation for both `h3` and `srvx` by
listening to their tracing channel events.
- `h3` TC PR: h3js/h3#1251
- `srvx` TC PR: h3js/srvx#141Closes#18123
---
**This PR is part of a stack:**
- #20358
- #19224
- #19225 👈
- #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 22, 2026
Adds automatic sourcemap handling to the Nitro SDK, using
`@sentry/bundler-plugin-core` for builder-agnostic post-build upload.
Nitro uses rollup or rolldown, so it made sense to make it as agnostic
as possible.
Closes#17992 ---
**This PR is part of a stack:**
- #20358
- #19224
- #19225
- #19304 👈
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 23, 2026
Implements HTTP server instrumentation for both `h3` and `srvx` by
listening to their tracing channel events.
- `h3` TC PR: h3js/h3#1251
- `srvx` TC PR: h3js/srvx#141Closes#18123
---
**This PR is part of a stack:**
- #20358
- #19224
- #19225 👈
- #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 23, 2026
Adds automatic sourcemap handling to the Nitro SDK, using
`@sentry/bundler-plugin-core` for builder-agnostic post-build upload.
Nitro uses rollup or rolldown, so it made sense to make it as agnostic
as possible.
Closes#17992 ---
**This PR is part of a stack:**
- #20358
- #19224
- #19225
- #19304 👈
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit that referenced this pull request Apr 23, 2026
This PR just isolates the mundane changes needed for a new SDK to keep
the next stacked PRs clean, it adds the Nitro SDK to the monorepo.
This PR is a base of a stack, the stacked PRs will be merged into it. I
thought this will be easier to review.
---
**This PR is part of a stack:**
- #20358
- #19224 👈
- #19225 - #19304
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@logaretm@timfish@s1gr1d