@sentry/node
- Version 8.30.0
- Published
- 2.63 MB
- 32 dependencies
- MIT license
Install
npm i @sentry/node
yarn add @sentry/node
pnpm add @sentry/node
Overview
Sentry Node SDK using OpenTelemetry for performance instrumentation
Index
Variables
Functions
- connectIntegration()
- consoleIntegration()
- contextLinesIntegration()
- createGetModuleFromFilename()
- expressErrorHandler()
- expressIntegration()
- fastifyIntegration()
- fsIntegration()
- generateInstrumentOnce()
- genericPoolIntegration()
- getAutoPerformanceIntegrations()
- getDefaultIntegrations()
- getDefaultIntegrationsWithoutPerformance()
- getSentryRelease()
- graphqlIntegration()
- hapiIntegration()
- httpIntegration()
- init()
- initOpenTelemetry()
- initWithoutDefaultIntegrations()
- kafkaIntegration()
- koaIntegration()
- localVariablesIntegration()
- makeNodeTransport()
- modulesIntegration()
- mongoIntegration()
- mongooseIntegration()
- mysql2Integration()
- mysqlIntegration()
- nativeNodeFetchIntegration()
- nestIntegration()
- nodeContextIntegration()
- onUncaughtExceptionIntegration()
- onUnhandledRejectionIntegration()
- postgresIntegration()
- preloadOpenTelemetry()
- prismaIntegration()
- redisIntegration()
- setupConnectErrorHandler()
- setupExpressErrorHandler()
- setupFastifyErrorHandler()
- setupHapiErrorHandler()
- setupKoaErrorHandler()
- setupNestErrorHandler()
- spotlightIntegration()
- validateOpenTelemetrySetup()
Classes
Interfaces
Variables
variable anrIntegration
const anrIntegration: AnrReturn;
variable cron
const cron: { instrumentCron: typeof instrumentCron; instrumentNodeCron: typeof instrumentNodeCron; instrumentNodeSchedule: typeof instrumentNodeSchedule;};
Methods to instrument cron libraries for Sentry check-ins
variable defaultStackParser
const defaultStackParser: StackParser;
Node.js stack parser
variable SentryContextManager
const SentryContextManager: new ( ...args: unknown[]) => AsyncLocalStorageContextManager;
This is a custom ContextManager for OpenTelemetry, which extends the default AsyncLocalStorageContextManager. It ensures that we create a new hub per context, so that the OTEL Context & the Sentry Hub are always in sync.
Note that we currently only support AsyncHooks with this, but since this should work for Node 14+ anyhow that should be good enough.
Functions
function connectIntegration
connectIntegration: () => any;
function consoleIntegration
consoleIntegration: () => any;
Capture console logs as breadcrumbs.
function contextLinesIntegration
contextLinesIntegration: (options?: ContextLinesOptions | undefined) => any;
Capture the lines before and after the frame's context.
function createGetModuleFromFilename
createGetModuleFromFilename: ( basePath?: string, isWindows?: boolean) => (filename: string | undefined) => string | undefined;
Creates a function that gets the module name from a filename
function expressErrorHandler
expressErrorHandler: (options?: ExpressHandlerOptions) => ExpressMiddleware;
An Express-compatible error handler.
function expressIntegration
expressIntegration: () => any;
Express integration
Capture tracing data for express. In order to capture exceptions, you have to call
setupExpressErrorHandler(app)
before any other middleware and after all controllers.
function fastifyIntegration
fastifyIntegration: () => any;
Express integration
Capture tracing data for fastify.
function fsIntegration
fsIntegration: ( options?: | { recordFilePaths?: boolean | undefined; recordErrorMessagesAsSpanAttributes?: boolean | undefined; } | undefined) => any;
This integration will create spans for
fs
API 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 generateInstrumentOnce
generateInstrumentOnce: <Options = unknown>( name: string, creator: (options?: Options) => Instrumentation) => ((options?: Options) => void) & { id: string };
Instrument an OpenTelemetry instrumentation once. This will skip running instrumentation again if it was already instrumented.
function genericPoolIntegration
genericPoolIntegration: () => any;
GenericPool integration
Capture tracing data for GenericPool.
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 getSentryRelease
getSentryRelease: (fallback?: string) => string | undefined;
Returns a release dynamically from environment variables.
function graphqlIntegration
graphqlIntegration: (options?: GraphqlOptions | undefined) => any;
GraphQL integration
Capture tracing data for GraphQL.
function hapiIntegration
hapiIntegration: () => any;
Hapi integration
Capture tracing data for Hapi. If you also want to capture errors, you need to call
setupHapiErrorHandler(server)
after you set up your server.
function httpIntegration
httpIntegration: (options?: HttpOptions | undefined) => any;
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) => void;
Initialize OpenTelemetry for Node.
function initWithoutDefaultIntegrations
initWithoutDefaultIntegrations: ( options?: NodeOptions | undefined) => NodeClient;
Initialize Sentry for Node, without any integrations added by default.
function kafkaIntegration
kafkaIntegration: () => any;
KafkaJs integration
Capture tracing data for KafkaJs.
function koaIntegration
koaIntegration: () => any;
function localVariablesIntegration
localVariablesIntegration: ( options?: LocalVariablesIntegrationOptions) => Integration;
function makeNodeTransport
makeNodeTransport: (options: NodeTransportOptions) => Transport;
Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.
function modulesIntegration
modulesIntegration: () => any;
Add node modules / packages to the event.
function mongoIntegration
mongoIntegration: () => any;
MongoDB integration
Capture tracing data for MongoDB.
function mongooseIntegration
mongooseIntegration: () => any;
Mongoose integration
Capture tracing data for Mongoose.
function mysql2Integration
mysql2Integration: () => any;
MySQL2 integration
Capture tracing data for mysql2
function mysqlIntegration
mysqlIntegration: () => any;
MySQL integration
Capture tracing data for mysql.
function nativeNodeFetchIntegration
nativeNodeFetchIntegration: (options?: NodeFetchOptions | undefined) => any;
function nestIntegration
nestIntegration: () => any;
Nest framework integration
Capture tracing data for nest.
function nodeContextIntegration
nodeContextIntegration: (options?: ContextOptions | undefined) => any;
Capture context about the environment and the device that the client is running on, to events.
function onUncaughtExceptionIntegration
onUncaughtExceptionIntegration: ( options?: Partial<OnUncaughtExceptionOptions> | undefined) => any;
Add a global exception handler.
function onUnhandledRejectionIntegration
onUnhandledRejectionIntegration: ( options?: Partial<OnUnhandledRejectionOptions> | undefined) => any;
Add a global promise rejection handler.
function postgresIntegration
postgresIntegration: () => any;
Postgres integration
Capture tracing data for pg.
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: () => any;
Prisma integration
Capture tracing data for prisma. Note: This requieres to set: previewFeatures = ["tracing"] For the prisma client. See https://www.prisma.io/docs/concepts/components/prisma-client/opentelemetry-tracing for more details.
function redisIntegration
redisIntegration: (options?: RedisOptions | undefined) => any;
Redis integration for "ioredis"
Capture tracing data for redis and ioredis.
function setupConnectErrorHandler
setupConnectErrorHandler: (app: ConnectApp) => void;
function setupExpressErrorHandler
setupExpressErrorHandler: ( app: { use: (middleware: ExpressMiddleware) => unknown }, options?: ExpressHandlerOptions) => void;
Setup an error handler for Express. The error handler must be before any other middleware and after all controllers.
function setupFastifyErrorHandler
setupFastifyErrorHandler: (fastify: Fastify) => void;
Setup an error handler for Fastify.
function setupHapiErrorHandler
setupHapiErrorHandler: (server: Server) => Promise<void>;
Add a Hapi plugin to capture errors to Sentry.
function setupKoaErrorHandler
setupKoaErrorHandler: (app: { use: (arg0: (ctx: any, next: any) => Promise<void>) => void;}) => void;
function setupNestErrorHandler
setupNestErrorHandler: ( app: MinimalNestJsApp, baseFilter: NestJsErrorFilter) => void;
Setup an error handler for Nest.
function spotlightIntegration
spotlightIntegration: ( options?: Partial<SpotlightConnectionOptions> | undefined) => any;
Use this integration to send errors and transactions to Spotlight.
Learn more about spotlight at https://spotlightjs.com
Important: This integration only works with Node 18 or newer.
function validateOpenTelemetrySetup
validateOpenTelemetrySetup: () => void;
Validate that your OpenTelemetry setup is correct.
Classes
class NodeClient
class NodeClient extends ServerRuntimeClient<NodeClientOptions> {}
A client for using Sentry with Node & OpenTelemetry.
constructor
constructor(options: NodeClientOptions);
property traceProvider
traceProvider: any;
property tracer
readonly tracer: Tracer;
Get the OTEL tracer.
method close
close: (timeout?: number | undefined) => PromiseLike<boolean>;
method flush
flush: (timeout?: number) => Promise<boolean>;
method startClientReportTracking
startClientReportTracking: () => void;
Will start tracking client reports for this client.
NOTICE: This method will create an interval that is periodically called and attach a
process.on('beforeExit')
hook. To clean up these resources, call.close()
when you no longer intend to use the client. Not doing so will result in a memory leak.
Interfaces
interface NodeOptions
interface NodeOptions extends Options<NodeTransportOptions>, BaseNodeOptions {}
Configuration options for the Sentry Node SDK
See Also
@sentry/types Options for more information.
Package Files (40)
- build/types/cron/index.d.ts
- build/types/index.d.ts
- build/types/integrations/anr/index.d.ts
- build/types/integrations/console.d.ts
- build/types/integrations/context.d.ts
- build/types/integrations/contextlines.d.ts
- build/types/integrations/fs.d.ts
- build/types/integrations/http.d.ts
- build/types/integrations/local-variables/index.d.ts
- build/types/integrations/modules.d.ts
- build/types/integrations/node-fetch.d.ts
- build/types/integrations/onuncaughtexception.d.ts
- build/types/integrations/onunhandledrejection.d.ts
- build/types/integrations/spotlight.d.ts
- build/types/integrations/tracing/connect.d.ts
- build/types/integrations/tracing/express.d.ts
- build/types/integrations/tracing/fastify.d.ts
- build/types/integrations/tracing/genericPool.d.ts
- build/types/integrations/tracing/graphql.d.ts
- build/types/integrations/tracing/hapi/index.d.ts
- build/types/integrations/tracing/index.d.ts
- build/types/integrations/tracing/kafka.d.ts
- build/types/integrations/tracing/koa.d.ts
- build/types/integrations/tracing/mongo.d.ts
- build/types/integrations/tracing/mongoose.d.ts
- build/types/integrations/tracing/mysql.d.ts
- build/types/integrations/tracing/mysql2.d.ts
- build/types/integrations/tracing/nest/nest.d.ts
- build/types/integrations/tracing/postgres.d.ts
- build/types/integrations/tracing/prisma.d.ts
- build/types/integrations/tracing/redis.d.ts
- build/types/otel/contextManager.d.ts
- build/types/otel/instrument.d.ts
- build/types/sdk/api.d.ts
- build/types/sdk/client.d.ts
- build/types/sdk/index.d.ts
- build/types/sdk/initOtel.d.ts
- build/types/transports/http.d.ts
- build/types/types.d.ts
- build/types/utils/module.d.ts
Dependencies (32)
- @opentelemetry/api
- @opentelemetry/context-async-hooks
- @opentelemetry/core
- @opentelemetry/instrumentation
- @opentelemetry/instrumentation-connect
- @opentelemetry/instrumentation-express
- @opentelemetry/instrumentation-fastify
- @opentelemetry/instrumentation-fs
- @opentelemetry/instrumentation-generic-pool
- @opentelemetry/instrumentation-graphql
- @opentelemetry/instrumentation-hapi
- @opentelemetry/instrumentation-http
- @opentelemetry/instrumentation-ioredis
- @opentelemetry/instrumentation-kafkajs
- @opentelemetry/instrumentation-koa
- @opentelemetry/instrumentation-mongodb
- @opentelemetry/instrumentation-mongoose
- @opentelemetry/instrumentation-mysql
- @opentelemetry/instrumentation-mysql2
- @opentelemetry/instrumentation-nestjs-core
- @opentelemetry/instrumentation-pg
- @opentelemetry/instrumentation-redis-4
- @opentelemetry/instrumentation-undici
- @opentelemetry/resources
- @opentelemetry/sdk-trace-base
- @opentelemetry/semantic-conventions
- @prisma/instrumentation
- @sentry/core
- @sentry/opentelemetry
- @sentry/types
- @sentry/utils
- import-in-the-middle
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[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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 4887 ms. - Missing or incorrect documentation? Open an issue for this package.