Guide
Node.js & Express
Node uses @sentry/node with one rule that matters: initialize the SDK before any other import, so http/express/db libraries get auto-instrumented.
instrument.js — first import wins
// instrument.js — MUST be imported before anything else
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: 'https://<publicKey>@jentry.app/<projectId>',
environment: process.env.NODE_ENV,
tracesSampleRate: 0.1,
});// index.js
import './instrument.js'; // ← first
import * as Sentry from '@sentry/node';
import express from 'express';
const app = express();
// …routes…
Sentry.setupExpressErrorHandler(app); // before your own error middleware
app.use(myErrorHandler);
app.listen(3000);What you get
- Unhandled exceptions and rejections as grouped issues with release/environment tags.
- Each request as a transaction with db/http child spans — the waterfall shows exactly where time went.
- Automatic N+1-query and slow-query issues detected from those spans, with span evidence.
- Cron check-ins via Sentry.withMonitor / the check-in API — see the Crons guide.
Prefer OpenTelemetry in Node? Point the OTLP exporter at your project instead — see the OpenTelemetry guide. Both paths can coexist.
Try jentry free
Hosted error tracking & performance monitoring. Works with your Sentry SDKs — send your first event in minutes.