Performance Monitoring

Learn more about how to configure our Performance integrations to get the best experience.

As soon as you define a tracesSampleRate for your Sentry SDK, Performance Monitoring will be enabled. This will automatically instrument and monitor the performance of your application.

If you’re adopting Performance in a high-throughput environment, we recommend testing prior to deployment to ensure that your service’s performance characteristics maintain expectations.

instrument.mjs
Copied
import * as Sentry from '@sentry/node';
import {BaseExceptionFilter, HttpAdapterHost, NestFactory} from '@nestjs/core';
import {AppModule} from './app.module';

async function bootstrap() {
  Sentry.init({
    dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',

    // Add Performance Monitoring by setting tracesSampleRate
    // We recommend adjusting this value in production
    tracesSampleRate: 1.0,
  });

  const app = await NestFactory.create(AppModule);
  const {httpAdapter} = app.get(HttpAdapterHost);

  Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));

  await app.listen(3000);
}

bootstrap();

See Automatic Instrumentation to learn about everything the SDK automatically instruments for you.

You can also manually start spans to instrument specific parts of your code. This is useful when you want to measure the performance of a specific operation or function.

See Custom Instrumentation to learn how to manually start spans.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").