Automatic Instrumentation

By default, Sentry's Node.js SDK can automatically instrument HTTP calls. In order for this to work, you have to create transactions which the HTTP calls will be added to as spans.

Read more about Custom Instrumentation to learn how to create transactions and add your own spans.

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

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [
    // Automatically instrument Node.js libraries and frameworks
    // (This function is slow because of file I/O, consider manually adding additional integrations instead)
    ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
    // Or manually add integrations of your choice. For example:
    new Sentry.Integrations.Apollo(),
    new Sentry.Integrations.Postgres(),
  ],

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,
});
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").