Skip to content

feat(nestjs): add orchestrion integration#21796

Closed
isaacs wants to merge 18 commits into
developfrom
isaacs/nestjs-orchestrion
Closed

feat(nestjs): add orchestrion integration#21796
isaacs wants to merge 18 commits into
developfrom
isaacs/nestjs-orchestrion

Conversation

@isaacs

@isaacs isaacs commented Jun 25, 2026

Copy link
Copy Markdown
Member

Add 'Nest' to the set of integrations that are implemented using Orchestrion, and which override a prior OTel based integration.

This is a port of the entire vendored OTel NestJS functionality to orchestrion-injected diagnostics channels.

The integration swap is moved into the _init method in the Node SDK, because the NestJS SDK (and other framework SDKs) will pass in its own defaultIntegrations array, which would bypass the old swap location. Now the swap is uniform for every framework SDK based on Node init, and respects defaultIntegrations: false.

Fix: JS-2519
Fix: #20947

@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch 2 times, most recently from 11c284e to 7fafc68 Compare June 26, 2026 16:27
@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from 7fafc68 to 3277391 Compare July 3, 2026 00:01
@isaacs isaacs marked this pull request as ready for review July 3, 2026 00:01
@isaacs isaacs requested a review from a team as a code owner July 3, 2026 00:01
@isaacs isaacs requested review from JPeer264, andreiborza and mydea and removed request for a team July 3, 2026 00:01
Comment thread packages/server-utils/src/orchestrion/config.ts Outdated
Comment thread packages/server-utils/src/integrations/tracing-channel/nestjs-decorators.ts Outdated
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.34 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.13 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.61 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.26 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.32 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.76 kB - -
@sentry/browser (incl. sendFeedback) 32.38 kB - -
@sentry/browser (incl. FeedbackAsync) 37.51 kB - -
@sentry/browser (incl. Metrics) 28.67 kB - -
@sentry/browser (incl. Logs) 28.91 kB - -
@sentry/browser (incl. Metrics & Logs) 29.59 kB - -
@sentry/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.61 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.24 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.32 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.81 kB - -
CDN Bundle (incl. Tracing, Replay) 85.84 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.14 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.92 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.1 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.07 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.75 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.92 kB - -
@sentry/nextjs (client) 51.16 kB - -
@sentry/sveltekit (client) 46.75 kB - -
@sentry/core/server 78.42 kB - -
@sentry/core/browser 64.74 kB - -
@sentry/node-core 62.72 kB +0.01% +1 B 🔺
@sentry/node 125.39 kB +0.05% +58 B 🔺
@sentry/node (incl. diagnostics channel injection) 135.04 kB +0.06% +68 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB +0.01% +4 B 🔺
@sentry/node/light 50.72 kB - -
@sentry/node - without tracing 74.11 kB +0.09% +62 B 🔺
@sentry/aws-serverless 85.56 kB +0.07% +57 B 🔺
@sentry/cloudflare (withSentry) - minified 181.71 kB - -
@sentry/cloudflare (withSentry) 449.16 kB - -

View base workflow run

@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from df77d10 to d1299b8 Compare July 3, 2026 17:07
Comment thread packages/node/src/sdk/index.ts
Comment thread packages/server-utils/src/integrations/tracing-channel/nestjs.ts Outdated
@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from aa02081 to f0ed876 Compare July 3, 2026 17:33
@andreiborza andreiborza requested a review from nicohrubec July 6, 2026 08:02
Comment thread dev-packages/node-integration-tests/suites/tracing/nestjs-orchestrion/test.ts Outdated
Comment thread packages/server-utils/src/integrations/tracing-channel/nestjs-decorators.ts Outdated
Comment thread packages/server-utils/src/orchestrion/channels.ts Outdated
Comment thread packages/server-utils/src/orchestrion/config.ts Outdated
@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from f0ed876 to 6c8af12 Compare July 6, 2026 23:06
Comment thread packages/nestjs/src/integrations/wrap-components.ts
@isaacs isaacs requested a review from nicohrubec July 7, 2026 02:07
@linear-code

linear-code Bot commented Jul 7, 2026

Copy link
Copy Markdown

JS-2519

@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from 8c0e65e to c1a0de0 Compare July 7, 2026 17:12
@isaacs isaacs enabled auto-merge (squash) July 7, 2026 17:13
Comment thread packages/server-utils/src/integrations/tracing-channel/nestjs-decorators.ts Outdated
Comment thread packages/node/src/sdk/index.ts
@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from 46283e9 to 99bea1b Compare July 7, 2026 18:22
Comment thread packages/nestjs/src/integrations/wrap-components.ts
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

👋 @mydea, @JPeer264, @andreiborza — Please review this PR when you get a chance!

@andreiborza

Copy link
Copy Markdown
Member

@isaacs this is a bit difficult to review and to keep everything in context. Could we maybe split this up into a stacked PR?

@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch 2 times, most recently from f030443 to 047d579 Compare July 8, 2026 20:09
@isaacs isaacs requested a review from a team as a code owner July 8, 2026 22:35
@isaacs isaacs requested review from chargome and removed request for a team July 8, 2026 22:35
isaacs added 17 commits July 8, 2026 15:35
Not yet wired into the NestJS SDK, but the initial channels and span
creation logic in place.
Port the entire vendored OTel core `instrumentation-nestjs-core`
functionality.

Still remaining are the 4 Sentry decorator instrumentations and then
wiring up the final `experimentalUseDiagnosticsChannelIntegration()`
piece with `replacedOtelIntegrationNames: ['Nest']` in the Node SDK,
and an E2E test to verify that it matches the OTel functionality.
Port the @Injectable and @catch decorators, so that the entire NestJS
OTel instrumentation is ported to Sentry Orchestrion implementation.

Not yet wired up into the `experimentalUseDiagnosticsChannelInjection`,
so still dormant at this stage.

Pieces to come in following commits:

- schedule (@Cron/@Interval/@timeout): error capture + isolation scope,
  no spans created
- event (@onevent), bullmq (@processor): all the same astQuery
  inner-arrow-function pattern.
- Final wire-in: add `experimentalUseDiagnosticsChannelInjection` +
  `replacedOtelIntegrationNames: ['Nest']` + opt-in e2e diffing against
  the OTel baseline.
Connect the `@Cron`/`@interval`/`@Timeout` (schedule), `@OnEvent`
(event), and `@Processor` (bullmq) instrumentations in the orchestrion
implementation.

At this point, it's still not wired up by default into the SDK, but all
of the functionality is there.

Next step is the final wire-up and opt-in to swap out the OTel NestJS
for this Orchestrion implementation.
Add `'Nest'` to the set of integrations that are implemented using
Orchestrion, and which override a prior OTel based integration.

The integration swap is moved into the `_init` method in the Node SDK,
because the NestJS SDK (and other framework SDKs) will pass in its own
defaultIntegrations array, which would bypass the old swap location. Now
the swap is uniform for every framework SDK based on Node init, and
respects `defaultIntegrations: false`.

A new unit test is added that proves the opt-out leaves the defaults
untouched, and opt-in replaces the named OTel integration with channel
integrations.
…ver-utils

Introduce a dependency-injection approach to setting orchestrion
configuration from a standalone SDK that is not a part of the "normal"
tracing integrations reasonable to put in server-utils.

This also allows for better DRY sharing of reusable components between
the OTel and Orchestrion implementations of the NestJS integration.

The major change is that certain items like the list of Orchestrion
instrumentations, need to be fetched on demand with a method, rather
than being a static `as const` array.

Dependency cycle is still avoided, but all NestJS code is now in
packages/nest where it belongs.
@isaacs isaacs force-pushed the isaacs/nestjs-orchestrion branch from 93be985 to 9eec1cc Compare July 8, 2026 22:36

@cursor cursor Bot 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 b34d60e. Configure here.

Comment thread packages/server-utils/src/orchestrion/runtime/register.ts
@isaacs

isaacs commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@andreiborza Yeah, that's fair.

I'm going to supersede this with a stack of PRs to do the following, more or less the exact reverse of what's going on in this one:

  1. Refactor server-utils a bit so that it's possible to dependency-inject a config into it (so the nestjs or any other standalone SDK can keep all its logic in one place)
  2. (ADDED) Extend isOrchestrionInjected(name?:string) so that you can ask if a specific integration is orchestrionified, and have registerDiagnosticsChannelInjection() record which ones actually are (to fix the clanker objection above).
  3. Refactor some of the vendored otel nestjs instrumentation into a shared location in packages/nestjs/src (so the orchestrion integration can use it)
  4. Implement the orchestrion NestJS integration (which should be much smaller, sitting on top of the other two)

Closing this in favor of that approach.

@isaacs isaacs closed this Jul 8, 2026
auto-merge was automatically disabled July 8, 2026 23:09

Pull request was closed

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.

Rewrite @opentelemetry/instrumentation-nestjs-core to orchestrion

3 participants