Database integrations

Node.js integrations support tracking database queries as spans. Starting in version 6.4.0, @sentry/tracing will auto-detect supported database drivers or ORMs being used in your project, and automatically enable the relevant integrations with default options - without needing additional code.

Supported packages and their integration name:

  • pg (Postgres)
  • pg-native (Postgres) Available from version 6.12.0
  • mongodb (Mongo)
  • mongoose (Mongo)
  • mysql (MySQL)

Disabling Automatic Instrumentation

You can also remove an automatically-enabled integration, if needed.

Manually Adding Integrations

If you need to add a specific database integration manually (for example, when using multiple client instances), you can import them from the @sentry/tracing package under the Integrations namespace.

For example:

Copied
const Sentry = require("@sentry/node");
const Tracing = require("@sentry/tracing");
const mongodb = require("mongodb");

const client = new Sentry.NodeClient({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [new Tracing.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!) to suggesting an update ("yeah, this would be better").