Commit 2cc1ef6
feat(node): Ensure
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×tamp=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×tamp=1757575780&yAxis=count%28%29
---------
Co-authored-by: Andrei <[email protected]>prismaIntegration works with Prisma v5 (#17595)1 parent fefb37d commit 2cc1ef6
File tree
27 files changed
+709
-5509
lines changed- dev-packages
- e2e-tests/test-applications
- node-koa
- react-router-7-framework-spa-node-20-18
- react-router-7-framework-spa
- node-integration-tests
- suites/tracing
- knex
- mysql2
- pg
- prisma-orm-v5
- prisma-orm-v6
- utils
- packages/node/src/integrations/tracing
27 files changed
+709
-5509
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
Lines changed: 0 additions & 312 deletions
This file was deleted.
0 commit comments