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)
  • mongodb (Mongo)
  • mongoose (Mongo)
  • mysql (MySQL)

Disabling Automatic Instrumentation

You can also (remove an automatically-enabled integration)integrations, 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, to add MongoDB instrumentation to a custom client:

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()],
});
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").