Prisma

Adds instrumentation for Prisma.

Import name: Sentry.prismaIntegration

Sentry supports tracing Prisma ORM queries with the Prisma integration.

The Prisma Integrations creates a spans for each query and reports to Sentry with relevant details inside description if available.

The Sentry Prisma Integration comes with Prisma version 5 support by default. For Prisma version 6 compatibility we need to pass a specific version of the Prisma instrumentation to the Sentry Prisma integration.

To use the integration with Prisma version 6, first install the @prisma/instrumentation package on version 6 (ideally the exact same version as your prisma and @prisma/client packages).

Then, add the prismaIntegration to your Sentry initialization as follows:

Copied
import { PrismaInstrumentation } from "@prisma/instrumentation";

Sentry.init({
  tracesSampleRate: 1.0,
  integrations: [
    Sentry.prismaIntegration({
      // Override the default instrumentation that Sentry uses
      prismaInstrumentation: new PrismaInstrumentation(),
    }),
  ],
});

To install the integration for Prisma version 5, first enable the tracing feature flag in the generator block of your Prisma schema:

schema.prisma
Copied
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["tracing"]
}

Then, add the prismaIntegration to your Sentry initialization as follows:

Copied
Sentry.init({
  tracesSampleRate: 1.0,
  integrations: [Sentry.prismaIntegration()],
});

Type: Instrumentation (An OpenTelemetry type)

Overrides the instrumentation used by the Sentry SDK with the passed in instrumentation instance.

  • prisma: >=5
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").