Skip to content

feat(nestjs)!: Remove import-in-the-middle instrumentation - #22805

Open
andreiborza wants to merge 6 commits into
developfrom
ab/js-3206-nestjs-channel-based
Open

feat(nestjs)!: Remove import-in-the-middle instrumentation#22805
andreiborza wants to merge 6 commits into
developfrom
ab/js-3206-nestjs-channel-based

Conversation

@andreiborza

@andreiborza andreiborza commented Jul 29, 2026

Copy link
Copy Markdown
Member

What

Migrate @sentry/nestjs fully to channel-based instrumentation.

  • Make the diagnostics-channel subscriber the only path in nestIntegration, removing the OpenTelemetry InstrumentationBase fallback.
  • Delete the vendored OTel Nest instrumentations and the SentryNest*Instrumentation classes.
  • Move the vendored enums next to their only consumer (wrap-route.ts) and drop the now-empty vendored/ tree.
  • Drop the unused @opentelemetry/instrumentation and @opentelemetry/api dependencies.
  • Port the unique OTel-path unit tests (Timeout mechanism, event name formatting, double-wrap and internal-skip guards) onto the channel path.

Why

Channel-based instrumentation is the default in v11 and node no longer registers the import-in-the-middle ESM loader hook. The OTel path in NestJS was already unreachable at runtime, so removing it drops dead code and two unused OpenTelemetry dependencies.

Closes: #22773

Migrate `@sentry/nestjs` fully to channel-based instrumentation and drop
the OpenTelemetry `InstrumentationBase` module patchers, so the package no
longer relies on the import-in-the-middle ESM loader hook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 29, 2026

Copy link
Copy Markdown

JS-3206

Comment on lines +73 to +91
const base = 'auto.middleware.orchestrion.nestjs';
return componentType ? `${base}.${componentType}` : base;
}

/**
* Origin for the app-creation / request-context / request-handler HTTP spans.
*/
export function httpOrigin(): string {
return isOrchestrionInjected() ? 'auto.http.orchestrion.nestjs' : 'auto.http.otel.nestjs';
return 'auto.http.orchestrion.nestjs';
}

/** Origin for `@OnEvent` spans. */
function eventOrigin(): string {
return isOrchestrionInjected() ? 'auto.event.orchestrion.nestjs' : 'auto.event.nestjs';
return 'auto.event.orchestrion.nestjs';
}

/** Origin for BullMQ `@Processor` `process` spans. */
function bullmqOrigin(): string {
return isOrchestrionInjected() ? 'auto.queue.orchestrion.nestjs.bullmq' : 'auto.queue.nestjs.bullmq';
return 'auto.queue.orchestrion.nestjs.bullmq';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I left them as .orchestrion. because Isaac's PR is removing these.

@andreiborza

andreiborza commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

batman begin

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c88c430. Configure here.

@andreiborza
andreiborza marked this pull request as ready for review July 29, 2026 10:25
@andreiborza
andreiborza requested a review from a team as a code owner July 29, 2026 10:25
@andreiborza
andreiborza requested review from JPeer264, nicohrubec and s1gr1d and removed request for a team and s1gr1d July 29, 2026 10:25
Comment thread packages/nestjs/test/orchestrion/nestjs.test.ts
@andreiborza andreiborza changed the title ref(nestjs): Remove import-in-the-middle instrumentation feat(nestjs)!: Remove import-in-the-middle instrumentation Jul 29, 2026
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.

Migrate @sentry/nestjs off import-in-the-middle to channel-based instrumentation

1 participant