getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
8.02k stars 1.59k forks source link

Sentry doesn't emit any instrumentation events when using Fastify adapter #14400

Open LuisCarrilloR opened 4 days ago

LuisCarrilloR commented 4 days ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.39.0

Framework Version

NestJS 10.3.10

Link to Sentry event

No response

Reproduction Example/SDK Setup

Having the following configuration, the app continously logs Isolation scope is still the default isolation scope, skipping setting transactionName.

// instrument.ts
import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.NODE_ENV,
  integrations: [nodeProfilingIntegration()],
  debug: true,
  release: process.env.NODE_ENV,
  enabled: process.env.API_TRACING_ENABLED === 'true',
  tracesSampler: (samplingContext) => {
    if (samplingContext?.transactionContext?.name === 'GET /') {
      return 0;
    }
    return 0.1;
  },
  profilesSampleRate: 1.0,
});
// main.ts
import * as dotenv from 'dotenv';
dotenv.config();

import '@shared/config/modules/sentry/instrument'; // Sentry import
import { NestFactory, Reflector } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';

async function bootstrap() {
  const adapter = new FastifyAdapter();

// some adapter configs here

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

  await app.listen(process.env.PORT ? parseInt(process.env.PORT) : 80, '0.0.0.0');
  console.log('Server runing in port', process.env.PORT || 'default (80)');
}
bootstrap();

Steps to Reproduce

  1. Setup Client.
  2. Init application.
    
    2024-11-21T00:03:16.243-06:00 | > node dist/main.js
    -- | --
      | 2024-11-21T00:03:20.015-06:00 | Sentry Logger [log]: Initializing Sentry: process: 18, thread: main.
      | 2024-11-21T00:03:20.018-06:00 | Sentry Logger [log]: Running in CommonJS mode.
      | 2024-11-21T00:03:20.022-06:00 | Sentry Logger [debug]: @opentelemetry/api: Registered a global for diag v1.9.0.
      | 2024-11-21T00:03:20.025-06:00 | Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.9.0.
      | 2024-11-21T00:03:20.025-06:00 | Sentry Logger [debug]: @opentelemetry/api: Registered a global for context v1.9.0.
      | 2024-11-21T00:03:20.026-06:00 | Sentry Logger [debug]: @opentelemetry/api: Registered a global for propagation v1.9.0.
      | 2024-11-21T00:03:34.513-06:00 | [Nest] 18 - 11/21/2024, 6:03:34 AM  LOG [NestFactory] Starting Nest application...
      | 2024-11-21T00:03:35.803-06:00 | [Nest] 18 - 11/21/2024, 6:03:35 AM  LOG [InstanceLoader] SentryModule dependencies initialized +1293ms
3. No transactions are detected.
4. Logs continuously show

Sentry Logger [warn]: Isolation scope is still the default isolation scope, skipping setting transactionName. Sentry Logger [warn]: Isolation scope is still the default isolation scope, skipping setting transactionName. Sentry Logger [warn]: Isolation scope is still the default isolation scope, skipping setting transactionName. Sentry Logger [log]: Flushing client reports based on interval. Sentry Logger [log]: Flushing outcomes... Sentry Logger [log]: No outcomes to send



### Expected Result

I expect to see at least some transactions in Sentry but nothing is being sent.

### Actual Result

Events are not being detected while using the app

![Image](https://github.com/user-attachments/assets/e4aff685-c7be-45d5-a02f-d1d666963e7d)
andreiborza commented 4 days ago

Hey @LuisCarrilloR, thanks for filing this.

Could you please provide a reproduction repo or stackblitz so we can try this?