Set Up Performance

Learn how to enable performance monitoring in your app.

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.js
Copied
const Sentry = require("@sentry/node");

// Ensure to call this before requiring any other modules!
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [
    // Add our Profiling integration
    nodeProfilingIntegration(),
  ],

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

  // Set sampling rate for profiling
  // This is relative to tracesSampleRate
  profilesSampleRate: 1.0,
});

See Automatic Instrumentation to learn about all the things that 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").