Auto-discovered
Node.js integrations support tracking database queries as spans. @sentry/node
can auto-detect supported database drivers or ORMs being used in your project.
Automatic discovery can fail if your code has been bundled. In that case you will need to manually add the required integrations.
Copied
const Sentry = require("@sentry/node");
const client = new Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations()],
});
Supported packages and their integration name:
pg
(Postgres)pg-native
(Postgres)mongodb
(Mongo)mongoose
(Mongo)mysql
(MySQL)graphql
(GraphQL)apollo-server-core
(Apollo)@nestjs/graphql
(Apollo)
If you need to add a specific database integration manually (for example, when using multiple client instances), you can import them from the Integrations
namespace.
For example:
Copied
const Sentry = require("@sentry/node");
const mongodb = require("mongodb");
const client = new Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [new Sentry.Integrations.Mongo({
useMongoose: true // Default: false
})],
});
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").
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").
- Package:
- npm:@sentry/node
- Version:
- 7.110.0
- Repository:
- https://github.com/getsentry/sentry-javascript