Skip to content

Commit 65afa6a

Browse files
authored
feat(node): Add Prisma v7 support (#18908)
Upgrades `@prisma/instrumentation` from `6.19.0` to `7.2.0`. The instrumentation should be backwards compatible with v5 and v6 (we have integration tests for v5 and v6). I also added integration tests for v7. Closes: #18876
1 parent 4695148 commit 65afa6a

14 files changed

Lines changed: 275 additions & 25 deletions

File tree

.size-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ module.exports = [
287287
import: createImport('init'),
288288
ignore: [...builtinModules, ...nodePrefixedBuiltinModules],
289289
gzip: true,
290-
limit: '164 KB',
290+
limit: '166 KB',
291291
},
292292
{
293293
name: '@sentry/node - without tracing',

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@nestjs/common": "^11",
3636
"@nestjs/core": "^11",
3737
"@nestjs/platform-express": "^11",
38+
"@prisma/adapter-pg": "7.2.0",
3839
"@prisma/client": "6.15.0",
3940
"@sentry/aws-serverless": "10.35.0",
4041
"@sentry/core": "10.35.0",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3.9'
2+
3+
services:
4+
db:
5+
image: postgres:13
6+
restart: always
7+
container_name: integration-tests-prisma-v7
8+
ports:
9+
- '5435:5432'
10+
environment:
11+
POSTGRES_USER: prisma
12+
POSTGRES_PASSWORD: prisma
13+
POSTGRES_DB: tests
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
Sentry.init({
5+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6+
release: '1.0',
7+
tracesSampleRate: 1.0,
8+
transport: loggingTransport,
9+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'prisma/config';
2+
3+
export default defineConfig({
4+
schema: './prisma/schema.prisma',
5+
migrations: './prisma/migrations',
6+
datasource: {
7+
url: 'postgresql://prisma:prisma@localhost:5435/tests',
8+
},
9+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "postgresql"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- CreateTable
2+
CREATE TABLE "User" (
3+
"id" SERIAL NOT NULL,
4+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
"email" TEXT NOT NULL,
6+
"name" TEXT,
7+
8+
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
9+
);
10+
11+
-- CreateIndex
12+
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
datasource db {
2+
provider = "postgresql"
3+
}
4+
5+
generator client {
6+
provider = "prisma-client"
7+
output = "./generated/prisma"
8+
}
9+
10+
model User {
11+
id Int @id @default(autoincrement())
12+
createdAt DateTime @default(now())
13+
email String @unique
14+
name String?
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"module": "ESNext",
4+
"moduleResolution": "bundler",
5+
"target": "ES2023",
6+
"declaration": false,
7+
"rewriteRelativeImportExtensions": true,
8+
"skipLibCheck": true
9+
},
10+
"include": ["./generated/prisma/**/*.ts"]
11+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { PrismaPg } from '@prisma/adapter-pg';
2+
import * as Sentry from '@sentry/node';
3+
import { randomBytes } from 'crypto';
4+
import { PrismaClient } from './prisma/generated/prisma/client.js';
5+
6+
// Stop the process from exiting before the transaction is sent
7+
setInterval(() => {}, 1000);
8+
9+
const connectionString = 'postgresql://prisma:prisma@localhost:5435/tests';
10+
11+
async function run() {
12+
await Sentry.startSpan(
13+
{
14+
name: 'Test Transaction',
15+
op: 'transaction',
16+
},
17+
async span => {
18+
const adapter = new PrismaPg({ connectionString });
19+
const client = new PrismaClient({ adapter });
20+
21+
await client.user.create({
22+
data: {
23+
name: 'Tilda',
24+
email: `tilda_${randomBytes(4).toString('hex')}@sentry.io`,
25+
},
26+
});
27+
28+
await client.user.findMany();
29+
30+
await client.user.deleteMany({
31+
where: {
32+
email: {
33+
contains: 'sentry.io',
34+
},
35+
},
36+
});
37+
38+
setTimeout(async () => {
39+
span.end();
40+
await client.$disconnect();
41+
}, 500);
42+
},
43+
);
44+
}
45+
46+
run();

0 commit comments

Comments
 (0)