Database integrations

Node.js has a few integrations that support tracking database queries as Spans. For now you only need to use the latest version of our SDK and add the specific integration to Sentry.init:

MongoDB

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

Sentry.init({
  // ....
  integrations: [
    // ....
    new Tracing.Integrations.Mongo(), // Add this integration
  ],
  // ....
});

MySQL / MariaDB

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

Sentry.init({
  // ....
  integrations: [
    // ....
    new Tracing.Integrations.Mysql(), // Add this integration
  ],
  // ....
});

PostgreSQL

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

Sentry.init({
  // ....
  integrations: [
    // ....
    new Tracing.Integrations.Postgres(), // Add this integration
  ],
  // ....
});
You can edit this page on GitHub.