Repository navigation
Closed
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
7.101.0
Framework Version
Node 18.18.2
Prisma 5.9.1
Link to Sentry event
SDK Setup
import { extraErrorDataIntegration } from "@sentry/integrations";
import { IS_AZURE_PRODUCTION, IS_STAGING } from "./constants";
import { ProfilingIntegration } from "@sentry/profiling-node";
import { SENTRY_DSN } from "../models/sentry/data";
import * as Sentry from "@sentry/node";
import prisma from "../client";
type CaptureContext = Parameters<typeof Sentry.captureException>[1];
if (IS_AZURE_PRODUCTION || IS_STAGING) {
Sentry.init({
debug: true,
dsn: SENTRY_DSN,
environment: IS_AZURE_PRODUCTION ? "production" : "staging",
integrations: [
new ProfilingIntegration(),
extraErrorDataIntegration({
depth: 4
}),
Sentry.anrIntegration({ captureStackTrace: true }),
Sentry.consoleIntegration(),
new Sentry.Integrations.GraphQL(),
new Sentry.Integrations.Prisma({ client: prisma })
],
profilesSampleRate: 1.0,
tracesSampleRate: 1.0
});
console.log(`🔦 Sentry initialized`);
}Steps to Reproduce
- Set up the Prisma integration with Sentry as per the setup guide (https://docs.sentry.io/platforms/node/performance/database/opt-in/#prisma-orm-integration)
- Execute an operation that makes a call to Prisma and records the span to Sentry
Expected Result
I should see information about the Prisma operation in the recorded Sentry span
Actual Result
I do not see anything about Prisma in the recorded Sentry span. In this case, Prisma executes before the http.client call in the below picture.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status

Activity
mydea commentedon Feb 15, 2024
We are currently working on v8 of the SDK which has a completely new prisma integration based on OpenTelemetry, which should support this much better out of the box.
What version of Prisma are you using? Maybe we have some incompatibility with a new Prisma version... 🤔
SheaBelsky commentedon Feb 15, 2024
Sorry, should have included that in my original message. I am using Prisma
5.9.1lforst commentedon Feb 16, 2024
Hi, for my side project I am using the prisma integration on the latest version and everything seems to work. Would you mind turning on
debug: truein your init options. We have a log message we print when you have a prisma client we don't support.SheaBelsky commentedon Feb 16, 2024
@lforst
Here's the output I get after loading Sentry and when I load a page which has a Prisma query:
This is using Sentry 7.101 and Prisma 5.9.1. Do I need to do anything else other than the setup below?
lforst commentedon Feb 16, 2024
The only thing that could be happening is that you are passing a different instance of the prisma client to sentry than you end up using. To avoid this, I am doing the following in my app:
It is a bit overly complex because it caters to my use-case but maybe it helps solve your case?
SheaBelsky commentedon Feb 16, 2024
Are you using a serverless setup or a regular server? I'm on a regular server setup, and I'm just following the Prisma documentation for instantiating a Prisma client once and reusing it.
https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#prismaclient-in-long-running-applications
I think you bring up a point though that perhaps Sentry is being initialized before Prisma is. I updated my Sentry setup file to be a function that is passed the Prisma client, and now I can see the Prisma span.
Is this kind of pattern OK? Should I expect any issues with Sentry if I do
Sentry.initinside of a function instead of right in the file itself?lforst commentedon Feb 16, 2024
Interesting. Generally, it shouldn't matter from where you call Sentry.init() but you should call it as early as possible in your code because it can only collect errors that happen after it was called.
I am using Next.js deployed to vercel, so kinda serverless.
SheaBelsky commentedon Feb 16, 2024
I'll keep playing with it, but my immediate issue is solved. Going to close this now. Thanks for your help!