Automatic Instrumentation

When integrating Sentry with an Express application, you can leverage provided middlewares to automatically instrument and monitor the performance of your application.

const Sentry = require("@sentry/node");
const express = require("express");
const app = express();

  dsn: "",
  integrations: [
    // enable Express.js middleware tracing
    new Sentry.Integrations.Express({
      // to trace all requests to the default router
      // alternatively, you can specify the routes you want to trace:
      // router: someRouter,
    // Automatically instrument Node.js libraries and frameworks

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,

// RequestHandler creates a separate execution context, so that all
// transactions/spans/breadcrumbs are isolated across requests
// TracingHandler creates a trace for every incoming request

// the rest of your app

// The Sentry error handler middleware must be registered before any other error middleware and after all controllers

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").