Skip to main content
The Sentry Node.js SDK provides comprehensive error monitoring and performance tracking for Node.js applications using OpenTelemetry instrumentation.

Installation

Basic Setup

Create an instrumentation file and import it before any other code:
Import the instrumentation file first in your application:
Or use Node.js --import flag:

Express Integration

Automatic instrumentation for Express.js:

Framework Integrations

Database Integrations

AI SDK Integrations

Performance Monitoring

Automatic Instrumentation

The SDK automatically instruments:
  • HTTP/HTTPS requests
  • Express/Fastify/Koa routes
  • Database queries
  • File system operations
  • Child processes

Custom Spans

Nested Spans

Error Handling

Automatic Capture

Manual Capture

Context & Scope

User Context

Request Isolation

Profiling

Enable CPU profiling:

Cron Monitoring

Monitor scheduled jobs:

Local Variables

Capture local variables in stack traces:

Context Lines

Capture source code context:

Best Practices

Import First

Always import the instrumentation file before any other code.

Use Integrations

Enable framework-specific integrations for automatic instrumentation.

Request Isolation

Use isolation scopes to separate context between requests.

Sampling

Adjust sample rates in production to control costs.

Configuration

Next Steps

Express

Express.js integration guide

Prisma

Prisma integration guide

OpenTelemetry

OpenTelemetry setup

Profiling

CPU profiling guide