Lightweight Mode

Learn about using @sentry/node-core in lightweight mode without OpenTelemetry.

If you don't need automatic spans/transactions, you can use @sentry/node-core/light which doesn't require OpenTelemetry dependencies. This mode is ideal when:

  • You only need error tracking, logs, or metrics without tracing data (no automatic span creation)
  • You want to minimize bundle size and runtime overhead
  • You don't need spans emitted by OpenTelemetry instrumentation

You still get error tracking, logs, metrics, breadcrumbs, context/user data, local variables capture, distributed tracing (via sentry-trace and baggage headers), and automatic request isolation (Node.js 22+).

If needed, you can still manually create spans by using Sentry's custom instrumentation APIs like startSpan.

  • Node.js 22.12.0+ is recommended for full functionality (automatic request isolation)
  • Lower Node.js versions work but with limited capabilities (see Request Isolation below)

Copied
npm install @sentry/node-core --save

Import from @sentry/node-core/light and call Sentry.init() as early as possible in your application lifecycle:

Copied
import * as Sentry from "@sentry/node-core/light";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
});

// Now create your HTTP server or framework app

To verify that Sentry is working, capture a test error:

Copied
Sentry.captureException(new Error("Sentry lightweight mode test"));

After running your application, you should see this error appear in your Sentry dashboard.

Request isolation ensures that errors, breadcrumbs, and context are correctly scoped to individual requests.

Request isolation works automatically. No additional setup is needed — just make sure Sentry.init() is called before you create your HTTP server.

You need to manually wrap your request handler with Sentry.withIsolationScope():

Copied
import * as Sentry from "@sentry/node-core/light";
import http from "http";

const server = http.createServer((req, res) => {
  Sentry.withIsolationScope(() => {
    // Your request handling code
    Sentry.setUser({ id: "user-id" });
    res.end("OK");
  });
});

@sentry/node@sentry/node-core/light
Error trackingYesYes
Logs and metricsYesYes
Automatic spansYesNo
OpenTelemetry auto-includedYesNo
Dependency footprintLargerMinimal
Best forFull observabilityNo auto-instrumentation, manual tracing setup

If you need automatic spans for HTTP requests, database queries, and other operations, use @sentry/node (the default). If you don't need automatically created spans and want minimal dependencies, use lightweight mode.

Was this helpful?
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").