Skip to content

feat(nestjs): Switch to OTel core instrumentation #17068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/nestjs/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,18 @@ function copyFunctionNameAndMetadata({
});

// copy metadata
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
if (typeof Reflect !== 'undefined' && typeof Reflect.getMetadataKeys === 'function') {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
const originalMetaData = Reflect.getMetadataKeys(originalMethod);
for (const key of originalMetaData) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
const value = Reflect.getMetadata(key, originalMethod);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
Reflect.defineMetadata(key, value, descriptor.value);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/nestjs/src/integrations/nest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NestInstrumentation as NestInstrumentationCore } from '@opentelemetry/instrumentation-nestjs-core';
import { defineIntegration } from '@sentry/core';
import { generateInstrumentOnce } from '@sentry/node';
import { NestInstrumentation } from './sentry-nest-core-instrumentation';
import { SentryNestEventInstrumentation } from './sentry-nest-event-instrumentation';
import { SentryNestInstrumentation } from './sentry-nest-instrumentation';

const INTEGRATION_NAME = 'Nest';

const instrumentNestCore = generateInstrumentOnce('Nest-Core', () => {
return new NestInstrumentation();
return new NestInstrumentationCore();
});

const instrumentNestCommon = generateInstrumentOnce('Nest-Common', () => {
Expand Down
307 changes: 0 additions & 307 deletions packages/nestjs/src/integrations/sentry-nest-core-instrumentation.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ export class SentryNestEventInstrumentation extends InstrumentationBase {
descriptor.value = async function (...args: unknown[]) {
// When multiple @OnEvent decorators are used on a single method, we need to get all event names
// from the reflector metadata as there is no information during execution which event triggered it
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
if (Reflect.getMetadataKeys(descriptor.value).includes('EVENT_LISTENER_METADATA')) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - reflect-metadata of nestjs adds these methods to Reflect
const eventData = Reflect.getMetadata('EVENT_LISTENER_METADATA', descriptor.value);
if (Array.isArray(eventData)) {
eventName = eventData
Expand Down
Loading