Skip to content

Commit 2cc1ef6

Browse files
mydeaandreiborza
andauthored
feat(node): Ensure prismaIntegration works with Prisma v5 (#17595)
This PR fixes the usage of the SDK in v10 with Prisma v5. We used to require/recommend that users manually installed `@prisma/instrumentation` v5 and passed this to our `prismaIntegration` like this: ```js const { PrismaInstrumentation } = require('@prisma/instrumentation'); prismaIntegration({ prismaInstrumentation: new PrismaInstrumentation() }); ``` However, this no longer works in v10 because that version pulls in v1 of `@opentelemetry/sdk-trace-base`, which is no longer compatible in v10 of our SDK 😢 So to fix this, this PR removes/deprecates the passing of `prismaInstrumentation` (this now no-ops). v5 is now supported out of the box! To make this work, some hacks and workarounds were necessary 😬 The problem is that v5 of the prisma instrumentation relies on manually creating span instances with specified ID and parent IDs. This is no longer possible in OTEL v2, as all these APIs are no longer exported 😞 (it was also weird from prisma to do this in the first place, and they no longer do this in v6 of the instrumentation). To get this to work, we manually overwrite the `tracer._idGenerator` with a mock that returns the IDs we need, kind of making this work as expected again. Hopefully this will not break in the future, we'll see - our tests should at least show us if that ever breaks. While at this, I also re-wrote our integration tests to run in CJS and ESM properly and use the new test runner structure instead of manually calling yarn etc. in there. Example trace before in v5 (without custom prismaInstrumentation, which broke at runtime): https://sentry-sdks.sentry.io/explore/discover/trace/49e2095162e4bb571074e27653586643/?dataset=transactions&field=title&field=project&field=user.display&field=timestamp&name=All%20Errors&node=span-61995a9d80c6925f&project=4508330866769920&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=1h&timestamp=1757575919&yAxis=count%28%29 Example trace with this PR: https://sentry-sdks.sentry.io/explore/discover/trace/deaaa1990ba6204085779aa09888dc2c/?dataset=transactions&field=title&field=project&field=user.display&field=timestamp&fov=0%2C813.7861328125&name=All%20Errors&node=span-8eb41978be76824e&project=4508330866769920&query=&queryDataset=transaction-like&sort=-timestamp&source=discover&statsPeriod=1h&timestamp=1757575780&yAxis=count%28%29 --------- Co-authored-by: Andrei <[email protected]>
1 parent fefb37d commit 2cc1ef6

File tree

27 files changed

+709
-5509
lines changed

27 files changed

+709
-5509
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
### Important Changes
88

9+
- **feat(node) Ensure `prismaIntegration` works with Prisma 5 ([#17595](https://github.com/getsentry/sentry-javascript/pull/17595))**
10+
11+
We used to require to pass in the v5 version of `@prisma/instrumentation` into `prismaIntegration({ prismaInstrumentation: new PrismaInstrumentation() })`, if you wanted to get full instrumentation for Prisma v5. However, it turns out this does not work on v10 of the SDK anymore, because `@prisma/instrumentation@5` requires OTEL v1.
12+
13+
With this release, we dropped the requirement to configure anything to get v5 support of Prisma. You do not need to configure anything in the integration anymore, and can remove the dependency on `@prisma/instrumentation@5` if you had it in your application. You only need to configure the `tracing` preview feature [according to our docs](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).
14+
915
- **feat(deps): Update OpenTelemetry dependencies ([#17558](https://github.com/getsentry/sentry-javascript/pull/17558))**
1016
- @opentelemetry/core bumped to ^2.1.0
1117
- @opentelemetry/context-async-hooks bumped to ^2.1.0

dev-packages/e2e-tests/test-applications/node-koa/yarn.lock

Lines changed: 0 additions & 312 deletions
This file was deleted.

0 commit comments

Comments
 (0)