[@sentry/node] Not working on [email protected]
Is there an existing issue for this?
- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [X] I have reviewed the documentation https://docs.sentry.io/
- [X] 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.108.0
Framework Version
Node v18.18.0
Link to Sentry event
No response
SDK Setup
import Sentry from "@sentry/node";
import { prisma } from "./db.js";
Sentry.init({
dsn: "https://[email protected]/xxx",
release: "1.0",
tracesSampleRate: 1.0,
integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
debug: true,
});
console.log("Sentry initialized");
Steps to Reproduce
I'm doing some queries on the prisma client having the sentry client initialized.
Expected Result
I never see anything in the Sentry Queries page.
Actual Result
I expect to see something in the Sentry Queries page.
I don't know where the issue lies. I can't find any errors or so when initializing.
Hello,
This may be related to https://github.com/getsentry/sentry-javascript/issues/10680, could you check the proposals from there?
Or alternatively, you could try @sentry/[email protected] - on the v8 branch, we have a completely new performance instrumentation system under the hood that may support Prisma (and other things!) better than before. There you do not need to add any integration or config yourself, it should just instrument it automatically.
I'm getting an error when using the alpha version:
...
backend:dev: Sentry Logger [log]: Integration installed: Fastify
backend:dev: Sentry Logger [log]: Integration installed: Graphql
backend:dev: Sentry Logger [log]: Integration installed: Mongo
backend:dev: Sentry Logger [log]: Integration installed: Mongoose
backend:dev: Sentry Logger [log]: Integration installed: Mysql
backend:dev: Sentry Logger [log]: Integration installed: Mysql2
backend:dev: Sentry Logger [log]: Integration installed: Postgres
backend:dev: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
backend:dev: TypeError: prismaInstrumentation.PrismaInstrumentation is not a constructor
backend:dev: at Object.setupOnce (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/integrations/tracing/prisma.ts:14:11)
backend:dev: at setupIntegration (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/integration.ts:134:105)
backend:dev: at file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/integration.ts:104:7
backend:dev: at Array.forEach (<anonymous>)
backend:dev: at setupIntegrations (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/integration.ts:101:16)
backend:dev: at NodeClient._setupIntegrations (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/baseclient.ts:520:20)
backend:dev: at NodeClient.init (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/baseclient.ts:305:12)
backend:dev: at Module.init (file:///C:/git/crm/node_modules/.pnpm/@[email protected]/node_modules/@sentry/src/sdk/init.ts:99:12)
backend:dev: at file:///C:/git/crm/packages/backend/src/sentry.ts:3:8
backend:dev: at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "https://[email protected]/xxx",
release: "1.0",
tracesSampleRate: 1.0,
debug: true,
});
console.log("Sentry initialized");
Ah, i see, sorry about that - we also noticed this already, there seems to be an issue with the Prisma integration in ESM builds 😬 we removed it from the default integrations but haven't published yet, I'll try to get a new alpha out today that should fix this issue, I'll ping you!
On 8.0.0@beta^3 still not fixed guys, just to add more information :) I know that is an issue of Prisma side, I put a +1 on their issue.
On 8.0.0@beta^3 still not fixed guys, just to add more information :) I know that is an issue of Prisma side, I put a +1 on their issue.
Thanks for the heads up! Just to clarify, on 8.0.0-beta.3, with a setup like this:
const Sentry = require('@sentry/node');
Sentry.init({
integrations: [Sentry.prismaIntegration()]
});
// Only require this _after_ Sentry was initialized!
const prisma = require('prisma');
// ...
You are not getting any prisma spans collected?
I tested with @sentry/[email protected] but it gives me an error during initialization. I followed the information on this page: https://docs.sentry.io/platforms/javascript/guides/express/performance/database/opt-in/#prismaintegration
node: v22.1.0
TypeError: prismaInstrumentation.PrismaInstrumentation is not a constructor
at Object.setupOnce (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\integrations\tracing\prisma.ts:13:9)
at setupIntegration (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\integration.ts:122:105)
at <anonymous> (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\integration.ts:93:7)
at Array.forEach (<anonymous>)
at setupIntegrations (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\integration.ts:90:16)
at NodeClient._setupIntegrations (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\baseclient.ts:554:20)
at NodeClient.init (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\baseclient.ts:313:12)
at _init (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\sdk\init.ts:169:12)
at Module.init (C:\git\crm\node_modules\.pnpm\@[email protected]\node_modules\@sentry\src\sdk\init.ts:104:10)
at <anonymous> (C:\git\crm\packages\backend\src\sentry.ts:6:8)
import * as Sentry from "@sentry/node";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
Sentry.init({
dsn: "https://[email protected]/xxx",
release: "1.0",
tracesSampleRate: process.env.NODE_ENV === "production" ? 0.2 : 1.0,
integrations: [nodeProfilingIntegration(), Sentry.prismaIntegration()],
});
console.log("Sentry initialized");
@hornta are you running your app in ESM mode (so not transpile it to CJS before running)? If yes, did you follow the ESM setup guide?
In particular, you'll need to start your app with the --require node argument
@hornta are you running your app in ESM mode (so not transpile it to CJS before running)? If yes, did you follow the ESM setup guide?
In particular, you'll need to start your app with the
--requirenode argument
I wasn't but am now but it didn't change anything. It still errors on TypeError: prismaInstrumentation.PrismaInstrumentation is not a constructor. Using sentry 8.4 and prisma 5.14 and node 22.1.
I have @prisma/instrumentation installed in my package.
I'm closing in favour of https://github.com/getsentry/sentry-javascript/issues/11216