Skip to content

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

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

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

Conversation

@logaretm
Copy link
Copy Markdown
Member

@logaretm logaretm commented Apr 16, 2026

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

@logaretm logaretm changed the title feat(opentelemetry): Add tracingChannel utility for TracingChannel context propagation feat(opentelemetry): Add tracingChannel utility for context propagation Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.88 kB - -
@sentry/browser - with treeshaking flags 24.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 flags 72.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/react 27.62 kB - -
@sentry/react (incl. Tracing) 46.01 kB - -
@sentry/vue 30.7 kB - -
@sentry/vue (incl. Tracing) 45.58 kB - -
@sentry/svelte 25.89 kB - -
CDN Bundle 28.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 - uncompressed 83.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 134.03 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.55 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 137.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 210.91 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 251.26 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 254.66 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 264.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 267.56 kB - -
@sentry/nextjs (client) 48.54 kB - -
@sentry/sveltekit (client) 44.18 kB - -
@sentry/node-core 57.97 kB +0.01% +5 B 🔺
@sentry/node 174.81 kB +0.01% +6 B 🔺
@sentry/node - without tracing 97.93 kB +0.03% +24 B 🔺
@sentry/aws-serverless 115.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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

File Description
packages/opentelemetry/src/tracingChannel.ts Implements the tracingChannel() wrapper and context binding logic.
packages/opentelemetry/test/tracingChannel.test.ts Adds unit tests for span activation, parent/child relationships, and context isolation.
packages/opentelemetry/rollup.npm.config.mjs Builds tracingChannel.ts as a separate entrypoint to keep Node-only deps out of the main bundle.
packages/opentelemetry/package.json Exposes ./tracingChannel subpath with ESM/CJS + types outputs.

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

Comment thread packages/opentelemetry/test/tracingChannel.test.ts
Comment thread packages/opentelemetry/src/tracingChannel.ts
Comment thread packages/opentelemetry/src/tracingChannel.ts
logaretm and 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 logaretm force-pushed the awad/tracing-channel-otel-vendoring branch from f3b037f to 1b87a8f Compare April 16, 2026 17:05
Comment thread packages/opentelemetry/src/tracingChannel.ts
Comment thread packages/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#141

Closes #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>
Copy link
Copy Markdown

@cursor cursor bot left a comment

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 thread packages/opentelemetry/test/tracingChannel.test.ts
@logaretm logaretm merged commit fa9fea2 into develop Apr 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#141

Closes #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#141

Closes #18123

---

**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 free to 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