@sentry/node
- Version 10.65.0
- Published
- 2.87 MB
- 9 dependencies
- MIT license
Install
npm i @sentry/nodeyarn add @sentry/nodepnpm add @sentry/nodeOverview
Sentry Node SDK using OpenTelemetry for performance instrumentation
Index
Variables
Functions
- amqplibIntegration()
- anthropicAIIntegration()
- buildLaunchDarklyFlagUsedHandler()
- connectIntegration()
- dataloaderIntegration()
- diagnosticsChannelInjectionIntegrations()
- experimentalUseDiagnosticsChannelInjection()
- expressIntegration()
- fastifyIntegration()
- firebaseIntegration()
- fsIntegration()
- genericPoolIntegration()
- getAutoPerformanceIntegrations()
- getDefaultIntegrations()
- getDefaultIntegrationsWithoutPerformance()
- googleGenAIIntegration()
- graphqlIntegration()
- hapiIntegration()
- honoIntegration()
- httpIntegration()
- init()
- initOpenTelemetry()
- initWithoutDefaultIntegrations()
- kafkaIntegration()
- knexIntegration()
- koaIntegration()
- langChainIntegration()
- langGraphIntegration()
- launchDarklyIntegration()
- lruMemoizerIntegration()
- mongoIntegration()
- mongooseIntegration()
- mysql2Integration()
- mysqlIntegration()
- nativeNodeFetchIntegration()
- openAIIntegration()
- openFeatureIntegration()
- postgresIntegration()
- postgresJsIntegration()
- preloadOpenTelemetry()
- prismaIntegration()
- redisIntegration()
- setupConnectErrorHandler()
- setupExpressErrorHandler()
- setupFastifyErrorHandler()
- setupHapiErrorHandler()
- setupHonoErrorHandler()
- setupKoaErrorHandler()
- statsigIntegration()
- tediousIntegration()
- unleashIntegration()
- vercelAIIntegration()
Classes
Interfaces
Variables
variable growthbookIntegration
const growthbookIntegration: any;Re-export the core GrowthBook integration for Node.js usage. The core integration is runtime-agnostic and works in both browser and Node environments.
Functions
function amqplibIntegration
amqplibIntegration: () => import('@sentry/core').Integration & { name: 'Amqplib';};Adds Sentry tracing instrumentation for the [amqplib](https://www.npmjs.com/package/amqplib) library.
For more information, see the [
amqplibIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/amqplib/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.amqplibIntegration()],});
function anthropicAIIntegration
anthropicAIIntegration: ( options?: AnthropicAiOptions | undefined) => import('@sentry/core').Integration & { name: 'Anthropic_AI' };Adds Sentry tracing instrumentation for the Anthropic AI SDK.
This integration is enabled by default.
When configured, this integration automatically instruments Anthropic AI SDK client instances to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
Example 1
import * as Sentry from '@sentry/node';Sentry.init({integrations: [Sentry.anthropicAIIntegration()],});## Options
-
recordInputs: Whether to record prompt messages (default: followsdataCollection.genAI.inputs, or the deprecatedsendDefaultPiioption) -recordOutputs: Whether to record response text (default: followsdataCollection.genAI.outputs, or the deprecatedsendDefaultPiioption)### Default Behavior
By default, the integration will: - Record inputs and outputs based on
dataCollection.genAIin your Sentry client options (or the deprecatedsendDefaultPiioption, for backwards compatibility) - Integration-levelrecordInputs/recordOutputsoptions take precedence over global configExample 2
// Always record inputs and outputs regardless of global dataCollection configSentry.init({integrations: [Sentry.anthropicAIIntegration({recordInputs: true,recordOutputs: true})],});// Never record inputs/outputs regardless of global dataCollection configSentry.init({dataCollection: { genAI: { inputs: true, outputs: true } },integrations: [Sentry.anthropicAIIntegration({recordInputs: false,recordOutputs: false})],});
function buildLaunchDarklyFlagUsedHandler
buildLaunchDarklyFlagUsedHandler: () => unknown;This is a shim for the LaunchDarkly flag used handler.
function connectIntegration
connectIntegration: () => import('@sentry/core').Integration & { name: 'Connect';};Adds Sentry tracing instrumentation for [Connect](https://github.com/senchalabs/connect/).
If you also want to capture errors, you need to call
setupConnectErrorHandler(app)after you initialize your connect app.For more information, see the [connect documentation](https://docs.sentry.io/platforms/javascript/guides/connect/).
Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.connectIntegration()],})
function dataloaderIntegration
dataloaderIntegration: () => import('@sentry/core').Integration & { name: 'Dataloader';};Adds Sentry tracing instrumentation for the [dataloader](https://www.npmjs.com/package/dataloader) library.
For more information, see the [
dataloaderIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/dataloader/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.dataloaderIntegration()],});
function diagnosticsChannelInjectionIntegrations
diagnosticsChannelInjectionIntegrations: () => any;function experimentalUseDiagnosticsChannelInjection
experimentalUseDiagnosticsChannelInjection: () => void;EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.
Call this BEFORE
Sentry.init():import * as Sentry from '@sentry/node';Sentry.experimentalUseDiagnosticsChannelInjection();Sentry.init({dsn: '__DSN__',// other settings...});When this has been called AND span recording is enabled,
Sentry.init()uses the diagnostics-channel-injection-based integrations instead of the OpenTelemetry ones, and installs the module hooks that inject the channels (so libraries imported afterinit()publish the channel events).This is a standalone function rather than an
init()option so that a bundler drops all of it (and its transitive deps) when this function isn't called.init()reads the loader registered below.An app that DOES call it gets the orchestrion code bundled as intended.
In an unbundled (server-side runtime) app this eagerly loads only the small subscriber/channel modules; the heavy code-transform dependencies stay lazy inside
register()and load only when injection actually runs.May change or be removed in any release.
Modifiers
@experimental
function expressIntegration
expressIntegration: ( options?: ExpressInstrumentationConfig | undefined) => import('@sentry/core').Integration & { name: 'Express' };function fastifyIntegration
fastifyIntegration: ( options?: Partial<FastifyIntegrationOptions> | undefined) => Integration & { name: string };Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).
If you also want to capture errors, you need to call
setupFastifyErrorHandler(app)after you set up your Fastify server.For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).
Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.fastifyIntegration()],})
function firebaseIntegration
firebaseIntegration: () => import('@sentry/core').Integration & { name: 'Firebase';};function fsIntegration
fsIntegration: ( options?: FsInstrumentationConfig | undefined) => import('@sentry/core').Integration & { name: 'FileSystem' };This integration will create spans for
fsAPI operations, like reading and writing files.**WARNING:** This integration may add significant overhead to your application. Especially in scenarios with a lot of file I/O, like for example when running a framework dev server, including this integration can massively slow down your application.
Parameter options
Configuration for this integration.
function genericPoolIntegration
genericPoolIntegration: () => import('@sentry/core').Integration & { name: 'GenericPool';};Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.
For more information, see the [
genericPoolIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.genericPoolIntegration()],});
function getAutoPerformanceIntegrations
getAutoPerformanceIntegrations: () => Integration[];With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.
function getDefaultIntegrations
getDefaultIntegrations: (options: Options) => Integration[];Get the default integrations for the Node SDK.
function getDefaultIntegrationsWithoutPerformance
getDefaultIntegrationsWithoutPerformance: () => Integration[];Get default integrations, excluding performance.
function googleGenAIIntegration
googleGenAIIntegration: ( options?: GoogleGenAIOptions | undefined) => import('@sentry/core').Integration & { name: 'Google_GenAI' };Adds Sentry tracing instrumentation for the Google Generative AI SDK.
This integration is enabled by default.
When configured, this integration automatically instruments Google GenAI SDK client instances to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
Example 1
import * as Sentry from '@sentry/node';Sentry.init({integrations: [Sentry.googleGenAiIntegration()],});## Options
-
recordInputs: Whether to record prompt messages (default: followsdataCollection.genAI.inputs) -recordOutputs: Whether to record response text (default: followsdataCollection.genAI.outputs)### Default Behavior
By default, the integration will: - Record inputs and outputs based on
dataCollection.genAIin your Sentry client options (or the deprecatedsendDefaultPiioption, for backwards compatibility) - Integration-levelrecordInputs/recordOutputsoptions take precedence over global configExample 2
// Always record inputs and outputs regardless of global dataCollection configSentry.init({integrations: [Sentry.googleGenAiIntegration({recordInputs: true,recordOutputs: true})],});// Never record inputs/outputs regardless of global dataCollection configSentry.init({dataCollection: { genAI: { inputs: true, outputs: true } },integrations: [Sentry.googleGenAiIntegration({recordInputs: false,recordOutputs: false})],});
function graphqlIntegration
graphqlIntegration: ( options?: GraphqlOptions | undefined) => import('@sentry/core').Integration & { name: 'Graphql' };Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.
For more information, see the [
graphqlIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).Parameter options
Configuration options for the GraphQL integration.
Example 1
```javascript const Sentry = require('@sentry/node');
Sentry.init({ integrations: [Sentry.graphqlIntegration()], });
function hapiIntegration
hapiIntegration: () => import('@sentry/core').Integration & { name: 'Hapi' };Adds Sentry tracing instrumentation for [Hapi](https://hapi.dev/).
If you also want to capture errors, you need to call
setupHapiErrorHandler(server)after you set up your server.For more information, see the [hapi documentation](https://docs.sentry.io/platforms/javascript/guides/hapi/).
Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.hapiIntegration()],})
function honoIntegration
honoIntegration: () => import('@sentry/core').Integration & { name: 'Hono' };Adds Sentry tracing instrumentation for [Hono](https://hono.dev/).
If you also want to capture errors, you need to call
setupHonoErrorHandler(app)after you set up your Hono server.For more information, see the [hono documentation](https://docs.sentry.io/platforms/javascript/guides/hono/).
Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.honoIntegration()],})Deprecated
Use the
@sentry/honopackage instead. Thesentry()middleware from@sentry/hono/nodehandles tracing and error capturing automatically without needing this integration orsetupHonoErrorHandler.
function httpIntegration
httpIntegration: ( options?: HttpOptions | undefined) => import('@sentry/core').Integration & { name: 'Http' };The http integration instruments Node's internal http and https modules. It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.
function init
init: (options?: NodeOptions | undefined) => NodeClient | undefined;Initialize Sentry for Node.
function initOpenTelemetry
initOpenTelemetry: ( client: NodeClient, options?: AdditionalOpenTelemetryOptions) => void;Initialize OpenTelemetry for Node.
function initWithoutDefaultIntegrations
initWithoutDefaultIntegrations: ( options?: NodeOptions | undefined) => NodeClient | undefined;Initialize Sentry for Node, without any integrations added by default.
function kafkaIntegration
kafkaIntegration: () => import('@sentry/core').Integration & { name: 'Kafka' };Adds Sentry tracing instrumentation for the [kafkajs](https://www.npmjs.com/package/kafkajs) library.
For more information, see the [
kafkaIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/kafka/).Example 1
```javascript const Sentry = require('@sentry/node');
Sentry.init({ integrations: [Sentry.kafkaIntegration()], });
function knexIntegration
knexIntegration: () => import('@sentry/core').Integration & { name: 'Knex' };Knex integration
Capture tracing data for [Knex](https://knexjs.org/).
Example 1
import * as Sentry from '@sentry/node';Sentry.init({integrations: [Sentry.knexIntegration()],});
function koaIntegration
koaIntegration: ( options?: KoaOptions | undefined) => import('@sentry/core').Integration & { name: 'Koa' };Adds Sentry tracing instrumentation for [Koa](https://koajs.com/).
If you also want to capture errors, you need to call
setupKoaErrorHandler(app)after you set up your Koa server.For more information, see the [koa documentation](https://docs.sentry.io/platforms/javascript/guides/koa/).
Parameter options
Configuration options for the Koa integration.
Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.koaIntegration()],})Example 2
// To ignore middleware spansconst Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.koaIntegration({ignoreLayersType: ['middleware']})],})
function langChainIntegration
langChainIntegration: ( options?: LangChainOptions | undefined) => import('@sentry/core').Integration & { name: 'LangChain' };Adds Sentry tracing instrumentation for LangChain.
This integration is enabled by default.
When configured, this integration automatically instruments LangChain runnable instances to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.
**Important:** This integration automatically skips wrapping the OpenAI, Anthropic, and Google GenAI providers to prevent duplicate spans when using LangChain with these AI providers. LangChain handles the instrumentation for all underlying AI providers.
Example 1
import * as Sentry from '@sentry/node';import { ChatOpenAI } from '@langchain/openai';Sentry.init({integrations: [Sentry.langChainIntegration()],dataCollection: { genAI: { inputs: true, outputs: true } }, // Enable to record inputs/outputs});// LangChain calls are automatically instrumentedconst model = new ChatOpenAI();await model.invoke("What is the capital of France?");## Manual Callback Handler
You can also manually add the Sentry callback handler alongside other callbacks:
Example 2
import * as Sentry from '@sentry/node';import { ChatOpenAI } from '@langchain/openai';const sentryHandler = Sentry.createLangChainCallbackHandler({recordInputs: true,recordOutputs: true});const model = new ChatOpenAI();await model.invoke("What is the capital of France?",{ callbacks: [sentryHandler, myOtherCallback] });## Options
-
recordInputs: Whether to record input messages/prompts (default: followsdataCollection.genAI.inputs, or the deprecatedsendDefaultPiioption) -recordOutputs: Whether to record response text (default: followsdataCollection.genAI.outputs, or the deprecatedsendDefaultPiioption)### Default Behavior
By default, the integration will: - Record inputs and outputs based on
dataCollection.genAIin your Sentry client options (or the deprecatedsendDefaultPiioption, for backwards compatibility) - Integration-levelrecordInputs/recordOutputsoptions take precedence over global configExample 3
// Always record inputs and outputs regardless of global dataCollection configSentry.init({integrations: [Sentry.langChainIntegration({recordInputs: true,recordOutputs: true})],});// Never record inputs/outputs regardless of global dataCollection configSentry.init({dataCollection: { genAI: { inputs: true, outputs: true } },integrations: [Sentry.langChainIntegration({recordInputs: false,recordOutputs: false})],});## Supported Events
The integration captures the following LangChain lifecycle events: - LLM/Chat Model: start, end, error (via callbacks) - Chain: start, end, error (via callbacks) - Tool: start, end, error (via callbacks) - Embeddings: embedQuery, embedDocuments (via direct method wrapping)
function langGraphIntegration
langGraphIntegration: ( options?: LangGraphOptions | undefined) => import('@sentry/core').Integration & { name: 'LangGraph' };Adds Sentry tracing instrumentation for LangGraph.
This integration is enabled by default.
When configured, this integration automatically instruments LangGraph StateGraph and compiled graph instances to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
Example 1
import * as Sentry from '@sentry/node';Sentry.init({integrations: [Sentry.langGraphIntegration()],});## Options
-
recordInputs: Whether to record prompt messages (default: followsdataCollection.genAI.inputs, or the deprecatedsendDefaultPiioption) -recordOutputs: Whether to record response text (default: followsdataCollection.genAI.outputs, or the deprecatedsendDefaultPiioption)### Default Behavior
By default, the integration will: - Record inputs and outputs based on
dataCollection.genAIin your Sentry client options (or the deprecatedsendDefaultPiioption, for backwards compatibility) - Integration-levelrecordInputs/recordOutputsoptions take precedence over global configExample 2
// Always record inputs and outputs regardless of global dataCollection configSentry.init({integrations: [Sentry.langGraphIntegration({recordInputs: true,recordOutputs: true})],});// Never record inputs/outputs regardless of global dataCollection configSentry.init({dataCollection: { genAI: { inputs: true, outputs: true } },integrations: [Sentry.langGraphIntegration({recordInputs: false,recordOutputs: false})],});## Captured Operations
The integration captures the following LangGraph operations: - **Agent Creation** (
StateGraph.compile()) - Creates agen_ai.create_agentspan - **Agent Invocation** (CompiledGraph.invoke()) - Creates agen_ai.invoke_agentspan## Captured Data
When
recordInputsandrecordOutputsare enabled, the integration captures: - Input messages from the graph state - Output messages and LLM responses - Tool calls made during agent execution - Agent and graph names - Available tools configured in the graph
function launchDarklyIntegration
launchDarklyIntegration: ( _options?: unknown) => import('@sentry/core').Integration & { name: 'LaunchDarkly' };This is a shim for the LaunchDarkly integration. We need this in order to not throw runtime errors when accidentally importing this on the server through a meta framework like Next.js.
function lruMemoizerIntegration
lruMemoizerIntegration: () => import('@sentry/core').Integration & { name: 'LruMemoizer';};Adds Sentry tracing instrumentation for the [lru-memoizer](https://www.npmjs.com/package/lru-memoizer) library.
For more information, see the [
lruMemoizerIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/lrumemoizer/).Example 1
```javascript const Sentry = require('@sentry/node');
Sentry.init({ integrations: [Sentry.lruMemoizerIntegration()], });
function mongoIntegration
mongoIntegration: () => import('@sentry/core').Integration & { name: 'Mongo' };Adds Sentry tracing instrumentation for the [mongodb](https://www.npmjs.com/package/mongodb) library.
For more information, see the [
mongoIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongo/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.mongoIntegration()],});
function mongooseIntegration
mongooseIntegration: () => import('@sentry/core').Integration & { name: 'Mongoose';};Adds Sentry tracing instrumentation for the [mongoose](https://www.npmjs.com/package/mongoose) library.
For more information, see the [
mongooseIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mongoose/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.mongooseIntegration()],});
function mysql2Integration
mysql2Integration: () => import('@sentry/core').Integration & { name: 'Mysql2' };Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.
For more information, see the [
mysql2Integrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.mysqlIntegration()],});
function mysqlIntegration
mysqlIntegration: () => import('@sentry/core').Integration & { name: 'Mysql' };Adds Sentry tracing instrumentation for the [mysql](https://www.npmjs.com/package/mysql) library.
For more information, see the [
mysqlIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.mysqlIntegration()],});
function nativeNodeFetchIntegration
nativeNodeFetchIntegration: ( options?: NodeFetchOptions | undefined) => import('@sentry/core').Integration & { name: 'NodeFetch' };Instrument outgoing fetch requests made through the native node
fetchAPI. This emits (depending on the integration options) spans and breadcrumbs, as well as injecting trace propagation headers into the request.
function openAIIntegration
openAIIntegration: ( options?: OpenAiOptions | undefined) => import('@sentry/core').Integration & { name: 'OpenAI' };Adds Sentry tracing instrumentation for the OpenAI SDK.
This integration is enabled by default.
When configured, this integration automatically instruments OpenAI SDK client instances to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
Example 1
import * as Sentry from '@sentry/node';Sentry.init({integrations: [Sentry.openAIIntegration()],});## Options
-
recordInputs: Whether to record input messages/prompts (default: followsdataCollection.genAI.inputs, or the deprecatedsendDefaultPiioption) -recordOutputs: Whether to record response text (default: followsdataCollection.genAI.outputs, or the deprecatedsendDefaultPiioption)### Default Behavior
By default, the integration will: - Record inputs and outputs based on
dataCollection.genAIin your Sentry client options (or the deprecatedsendDefaultPiioption, for backwards compatibility) - Integration-levelrecordInputs/recordOutputsoptions take precedence over global configExample 2
// Always record inputs and outputs regardless of global dataCollection configSentry.init({integrations: [Sentry.openAIIntegration({recordInputs: true,recordOutputs: true})],});// Never record inputs/outputs regardless of global dataCollection configSentry.init({dataCollection: { genAI: { inputs: true, outputs: true } },integrations: [Sentry.openAIIntegration({recordInputs: false,recordOutputs: false})],});
function openFeatureIntegration
openFeatureIntegration: ( _options?: unknown) => import('@sentry/core').Integration & { name: 'OpenFeature' };This is a shim for the OpenFeature integration. We need this in order to not throw runtime errors when accidentally importing this on the server through a meta framework like Next.js.
function postgresIntegration
postgresIntegration: ( options?: PostgresIntegrationOptions | undefined) => import('@sentry/core').Integration & { name: 'Postgres' };Adds Sentry tracing instrumentation for the [pg](https://www.npmjs.com/package/pg) library.
For more information, see the [
postgresIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.postgresIntegration()],});
function postgresJsIntegration
postgresJsIntegration: ( options?: PostgresJsInstrumentationConfig | undefined) => import('@sentry/core').Integration & { name: 'PostgresJs' };Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.
For more information, see the [
postgresIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.postgresJsIntegration()],});
function preloadOpenTelemetry
preloadOpenTelemetry: (options?: NodePreloadOptions) => void;Preload OpenTelemetry for Node. This can be used to preload instrumentation early, but set up Sentry later. By preloading the OTEL instrumentation wrapping still happens early enough that everything works.
function prismaIntegration
prismaIntegration: ( options?: PrismaOptions | undefined) => import('@sentry/core').Integration & { name: 'Prisma' };Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library. For more information, see the [
prismaIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).NOTE: This integration works out of the box with Prisma v6, and v7. On Prisma versions prior to v6, add
previewFeatures = ["tracing"]to the client generator block of your Prisma schema:``` generator client { provider = "prisma-client-js" previewFeatures = ["tracing"] } ```
function redisIntegration
redisIntegration: ( options?: RedisOptions | undefined) => import('@sentry/core').Integration & { name: 'Redis' };Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and [ioredis](https://www.npmjs.com/package/ioredis) libraries.
For more information, see the [
redisIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.redisIntegration()],});
function setupConnectErrorHandler
setupConnectErrorHandler: (app: ConnectApp) => void;Add a Connect middleware to capture errors to Sentry.
Parameter app
The Connect app to attach the error handler to
Example 1
const Sentry = require('@sentry/node');const connect = require("connect");const app = connect();Sentry.setupConnectErrorHandler(app);// Add you connect routes hereapp.listen(3000);
function setupExpressErrorHandler
setupExpressErrorHandler: ( app: { use: (middleware: any) => unknown }, options?: ExpressHandlerOptions) => void;function setupFastifyErrorHandler
setupFastifyErrorHandler: ( fastify: FastifyMinimal, options?: Partial<FastifyHandlerOptions>) => void;Add an Fastify error handler to capture errors to Sentry.
Parameter fastify
The Fastify instance to which to add the error handler
Parameter options
Configuration options for the handler
Example 1
const Sentry = require('@sentry/node');const Fastify = require("fastify");const app = Fastify();Sentry.setupFastifyErrorHandler(app);// Add your routes, etc.app.listen({ port: 3000 });
function setupHapiErrorHandler
setupHapiErrorHandler: (server: Server) => Promise<void>;Add a Hapi plugin to capture errors to Sentry.
Parameter server
The Hapi server to attach the error handler to
Example 1
const Sentry = require('@sentry/node');const Hapi = require('@hapi/hapi');const init = async () => {const server = Hapi.server();// all your routes hereawait Sentry.setupHapiErrorHandler(server);await server.start();};
function setupHonoErrorHandler
setupHonoErrorHandler: ( app: { use: MiddlewareHandlerInterface }, options?: Partial<HonoHandlerOptions>) => void;Add a Hono error handler to capture errors to Sentry.
Parameter app
The Hono instances
Parameter options
Configuration options for the handler
Example 1
const Sentry = require('@sentry/node');const { Hono } = require("hono");const app = new Hono();Sentry.setupHonoErrorHandler(app);// Add your routes, etc.Deprecated
Use the
@sentry/honopackage instead. Thesentry()middleware from@sentry/hono/nodehandles error capturing automatically without needing this function orhonoIntegration.
function setupKoaErrorHandler
setupKoaErrorHandler: (app: { use: (arg0: (ctx: any, next: any) => Promise<void>) => void;}) => void;Add an Koa error handler to capture errors to Sentry.
The error handler must be before any other middleware and after all controllers.
Parameter app
The Express instances
Parameter options
Configuration options for the handler
Example 1
const Sentry = require('@sentry/node');const Koa = require("koa");const app = new Koa();Sentry.setupKoaErrorHandler(app);// Add your routes, etc.app.listen(3000);
function statsigIntegration
statsigIntegration: ( _options?: unknown) => import('@sentry/core').Integration & { name: 'Statsig' };This is a shim for the Statsig integration. We need this in order to not throw runtime errors when accidentally importing this on the server through a meta framework like Next.js.
function tediousIntegration
tediousIntegration: () => import('@sentry/core').Integration & { name: 'Tedious';};Adds Sentry tracing instrumentation for the [tedious](https://www.npmjs.com/package/tedious) library.
For more information, see the [
tediousIntegrationdocumentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/tedious/).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.tediousIntegration()],});
function unleashIntegration
unleashIntegration: ( _options?: unknown) => import('@sentry/core').Integration & { name: 'Unleash' };This is a shim for the Unleash integration. We need this in order to not throw runtime errors when accidentally importing this on the server through a meta framework like Next.js.
function vercelAIIntegration
vercelAIIntegration: ( options?: VercelAiOptions | undefined) => import('@sentry/core').Integration & { name: 'VercelAI' };Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
For more information, see the [
aidocumentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).Example 1
const Sentry = require('@sentry/node');Sentry.init({integrations: [Sentry.vercelAIIntegration()],});This integration adds tracing support to all
aifunction calls. You need to opt-in to collecting spans for a specific call, you can do so by settingexperimental_telemetry.isEnabledtotruein the first argument of the function call.const result = await generateText({model: openai('gpt-4-turbo'),experimental_telemetry: { isEnabled: true },});If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each function call by setting
experimental_telemetry.recordInputsandexperimental_telemetry.recordOutputstotrue.```javascript const result = await generateText({ model: openai('gpt-4-turbo'), experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true }, });
Classes
class OpenFeatureIntegrationHook
class OpenFeatureIntegrationHookShim {}This is a shim for the OpenFeature integration hook.
Interfaces
interface NodeOptions
interface NodeOptions extends Options<NodeTransportOptions>, BaseNodeOptions {}Configuration options for the Sentry Node SDK
See Also
@sentry/core Options for more information.
Package Files (43)
- build/types/index.d.ts
- build/types/integrations/featureFlagShims/growthbook.d.ts
- build/types/integrations/featureFlagShims/launchDarkly.d.ts
- build/types/integrations/featureFlagShims/openFeature.d.ts
- build/types/integrations/featureFlagShims/statsig.d.ts
- build/types/integrations/featureFlagShims/unleash.d.ts
- build/types/integrations/fs/index.d.ts
- build/types/integrations/http.d.ts
- build/types/integrations/node-fetch.d.ts
- build/types/integrations/tracing/amqplib/index.d.ts
- build/types/integrations/tracing/anthropic-ai/index.d.ts
- build/types/integrations/tracing/connect/index.d.ts
- build/types/integrations/tracing/dataloader/index.d.ts
- build/types/integrations/tracing/express.d.ts
- build/types/integrations/tracing/fastify/index.d.ts
- build/types/integrations/tracing/firebase/firebase.d.ts
- build/types/integrations/tracing/genericPool/index.d.ts
- build/types/integrations/tracing/google-genai/index.d.ts
- build/types/integrations/tracing/graphql/index.d.ts
- build/types/integrations/tracing/hapi/index.d.ts
- build/types/integrations/tracing/hono/index.d.ts
- build/types/integrations/tracing/index.d.ts
- build/types/integrations/tracing/kafka/index.d.ts
- build/types/integrations/tracing/knex/index.d.ts
- build/types/integrations/tracing/koa/index.d.ts
- build/types/integrations/tracing/langchain/index.d.ts
- build/types/integrations/tracing/langgraph/index.d.ts
- build/types/integrations/tracing/lrumemoizer/index.d.ts
- build/types/integrations/tracing/mongo/index.d.ts
- build/types/integrations/tracing/mongoose/index.d.ts
- build/types/integrations/tracing/mysql/index.d.ts
- build/types/integrations/tracing/mysql2/index.d.ts
- build/types/integrations/tracing/openai/index.d.ts
- build/types/integrations/tracing/postgres/index.d.ts
- build/types/integrations/tracing/postgresjs.d.ts
- build/types/integrations/tracing/prisma/index.d.ts
- build/types/integrations/tracing/redis/index.d.ts
- build/types/integrations/tracing/tedious/index.d.ts
- build/types/integrations/tracing/vercelai/index.d.ts
- build/types/sdk/experimentalUseDiagnosticsChannelInjection.d.ts
- build/types/sdk/index.d.ts
- build/types/sdk/initOtel.d.ts
- build/types/types.d.ts
Dependencies (9)
Dev Dependencies (1)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@sentry/node.
- Markdown[](https://www.jsdocs.io/package/@sentry/node)
- HTML<a href="https://www.jsdocs.io/package/@sentry/node"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5249 ms. - Missing or incorrect documentation? Open an issue for this package.
