sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Unable to instrument Nestjs app when the Fastify Adapter is used

Open samuelgoldenbaum opened this issue 6 months ago • 5 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.26.0

Framework Version

@nestjs/platform-fastify ^10.4.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

The following will not instrument...

const initSentry = (): Promise<void> => {
  return new Promise((resolve) => {
    Sentry.init({
      dsn: 'DSN,
      integrations: [nodeProfilingIntegration()],
      tracesSampleRate: 1.0,
      profilesSampleRate: 1.0
    });
    return resolve();
  });
};

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter()
  );

  await app.listen(3000);
}

initSentry().then(() => bootstrap());

But using Express will

const initSentry = (): Promise<void> => {
  return new Promise((resolve) => {
    Sentry.init({
      dsn: 'DSN',
      integrations: [nodeProfilingIntegration()],
      tracesSampleRate: 1.0,
      profilesSampleRate: 1.0
    });
    return resolve();
  });
};

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  await app.listen(3000);
}

initSentry().then(() => bootstrap());

Steps to Reproduce

Swap to the Fastify adapter:

  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter()
  );

  await app.listen(3000);

Expected Result

Should instrument and show data in Performance tab

Actual Result

No instrumentation

samuelgoldenbaum avatar Aug 15 '24 03:08 samuelgoldenbaum