Prisma for Cloudflare

Adds instrumentation for Prisma ORM queries on Cloudflare Workers.

Import name: Sentry.prismaIntegration

Sentry supports tracing Prisma ORM queries with the Prisma integration. The integration creates a span for each query and reports relevant details to Sentry.

The integration relies on Node.js APIs, so your Worker must run with the nodejs_compat compatibility flag. Add the prismaIntegration to your instrument.server.ts file:

src/instrument.server.ts
Copied
import * as Sentry from "@sentry/cloudflare";

export default Sentry.defineCloudflareOptions((env) => ({
  dsn: "___PUBLIC_DSN___",
  tracesSampleRate: 1.0,
integrations: [Sentry.prismaIntegration()],
}));

This integration supports Prisma versions 5, 6, 7, and 8. In Prisma v5, you also need to add the tracing preview feature to the generator block of your Prisma schema:

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

Prisma 8 has no built-in tracing, so the SDK instruments it through diagnostics channels. If channel injection is disabled (enableRuntimeChannelInjection: false without build-time injection), no Prisma 8 spans are created. Each ORM call creates a prisma:client:operation span with the pg query spans nested underneath. db.sql, db.raw, and groupBy calls only create pg query spans.

  • prisma: 5.x, 6.x, 7.x, 8.x

For details on the span structure that Prisma's OpenTelemetry tracing produces in Prisma versions 5 to 7 (e.g., prisma:client:operation, prisma:engine:db_query), see the Prisma trace output documentation.

Was this helpful?
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").