feat(opentelemetry): Add tracingChannel utility for context propagation#20358
Conversation
size-limit report π¦
|
There was a problem hiding this comment.
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.tsimplementingtracingChannel()with ALS-backed context propagation viabindStore. - Added a new
./tracingChannelpackage 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.
β¦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) <[email protected]>
β¦a framework held together by ductape
f3b037f to
1b87a8f
Compare
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) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
β 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.
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>
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) <[email protected]>

otel-tracing-channelinto@sentry/opentelemetrytracingChannel()wrapper around Node.jsTracingChannelthat automatically binds OTel context propagation viabindStoregetAsyncLocalStorageLookup()API to access the ALS instead of relying on OTel private_asyncLocalStorageinternalssubscribe/unsubscribeaccept partial subscriber objects so callers only provide handlers they needThe util is exposed in a subpath export because nextjs does not externalize
node:diagnostic_channelsand will crash.