-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(node): Add compatibility layer for Prisma v5 #15169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "sentry-prisma-test", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"db-up": "docker compose up -d", | ||
"generate": "prisma generate", | ||
"migrate": "prisma migrate dev -n sentry-test", | ||
"setup": "run-s --silent db-up generate migrate" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@prisma/client": "5.22.0", | ||
"prisma": "5.22.0" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/scenario.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const Sentry = require('@sentry/node'); | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
integrations: [Sentry.prismaIntegration()], | ||
}); | ||
|
||
const { randomBytes } = require('crypto'); | ||
const { PrismaClient } = require('@prisma/client'); | ||
|
||
// Stop the process from exiting before the transaction is sent | ||
setInterval(() => {}, 1000); | ||
|
||
async function run() { | ||
const client = new PrismaClient(); | ||
|
||
await Sentry.startSpanManual( | ||
{ | ||
name: 'Test Transaction', | ||
op: 'transaction', | ||
}, | ||
async span => { | ||
await client.user.create({ | ||
data: { | ||
name: 'Tilda', | ||
email: `tilda_${randomBytes(4).toString('hex')}@sentry.io`, | ||
}, | ||
}); | ||
|
||
await client.user.findMany(); | ||
|
||
await client.user.deleteMany({ | ||
where: { | ||
email: { | ||
contains: 'sentry.io', | ||
}, | ||
}, | ||
}); | ||
|
||
setTimeout(async () => { | ||
span.end(); | ||
await client.$disconnect(); | ||
}, 500); | ||
}, | ||
); | ||
} | ||
|
||
run(); |
69 changes: 69 additions & 0 deletions
69
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { createRunner } from '../../../utils/runner'; | ||
|
||
describe('Prisma ORM Tests', () => { | ||
test('CJS - should instrument PostgreSQL queries from Prisma ORM', done => { | ||
createRunner(__dirname, 'scenario.js') | ||
.expect({ | ||
transaction: transaction => { | ||
expect(transaction.transaction).toBe('Test Transaction'); | ||
const spans = transaction.spans || []; | ||
expect(spans.length).toBeGreaterThanOrEqual(5); | ||
|
||
expect(spans).toContainEqual( | ||
expect.objectContaining({ | ||
data: { | ||
method: 'create', | ||
model: 'User', | ||
name: 'User.create', | ||
'sentry.origin': 'auto.db.otel.prisma', | ||
}, | ||
description: 'prisma:client:operation', | ||
status: 'ok', | ||
}), | ||
); | ||
|
||
expect(spans).toContainEqual( | ||
expect.objectContaining({ | ||
data: { | ||
'sentry.origin': 'auto.db.otel.prisma', | ||
}, | ||
description: 'prisma:client:serialize', | ||
status: 'ok', | ||
}), | ||
); | ||
|
||
expect(spans).toContainEqual( | ||
expect.objectContaining({ | ||
data: { | ||
'sentry.origin': 'auto.db.otel.prisma', | ||
}, | ||
description: 'prisma:client:connect', | ||
status: 'ok', | ||
}), | ||
); | ||
expect(spans).toContainEqual( | ||
expect.objectContaining({ | ||
data: { | ||
method: 'findMany', | ||
model: 'User', | ||
name: 'User.findMany', | ||
'sentry.origin': 'auto.db.otel.prisma', | ||
}, | ||
description: 'prisma:client:operation', | ||
status: 'ok', | ||
}), | ||
); | ||
expect(spans).toContainEqual( | ||
expect.objectContaining({ | ||
data: { | ||
'sentry.origin': 'auto.db.otel.prisma', | ||
}, | ||
description: 'prisma:client:serialize', | ||
status: 'ok', | ||
}), | ||
); | ||
}, | ||
}) | ||
.start(done); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/yarn.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@prisma/[email protected]": | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.22.0.tgz#da1ca9c133fbefe89e0da781c75e1c59da5f8802" | ||
integrity sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA== | ||
|
||
"@prisma/[email protected]": | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-5.22.0.tgz#58af56ed7f6f313df9fb1042b6224d3174bbf412" | ||
integrity sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ== | ||
|
||
"@prisma/engines-version@5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2": | ||
version "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2" | ||
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz#d534dd7235c1ba5a23bacd5b92cc0ca3894c28f4" | ||
integrity sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ== | ||
|
||
"@prisma/[email protected]": | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-5.22.0.tgz#28f3f52a2812c990a8b66eb93a0987816a5b6d84" | ||
integrity sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA== | ||
dependencies: | ||
"@prisma/debug" "5.22.0" | ||
"@prisma/engines-version" "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2" | ||
"@prisma/fetch-engine" "5.22.0" | ||
"@prisma/get-platform" "5.22.0" | ||
|
||
"@prisma/[email protected]": | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz#4fb691b483a450c5548aac2f837b267dd50ef52e" | ||
integrity sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA== | ||
dependencies: | ||
"@prisma/debug" "5.22.0" | ||
"@prisma/engines-version" "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2" | ||
"@prisma/get-platform" "5.22.0" | ||
|
||
"@prisma/[email protected]": | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-5.22.0.tgz#fc675bc9d12614ca2dade0506c9c4a77e7dddacd" | ||
integrity sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q== | ||
dependencies: | ||
"@prisma/debug" "5.22.0" | ||
|
||
[email protected]: | ||
version "2.3.3" | ||
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" | ||
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== | ||
|
||
[email protected]: | ||
version "5.22.0" | ||
resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.22.0.tgz#1f6717ff487cdef5f5799cc1010459920e2e6197" | ||
integrity sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A== | ||
dependencies: | ||
"@prisma/engines" "5.22.0" | ||
optionalDependencies: | ||
fsevents "2.3.3" |
13 changes: 13 additions & 0 deletions
13
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/docker-compose.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3.9' | ||
|
||
services: | ||
db: | ||
image: postgres:13 | ||
restart: always | ||
container_name: integration-tests-prisma-v6 | ||
ports: | ||
- '5434:5432' | ||
environment: | ||
POSTGRES_USER: prisma | ||
POSTGRES_PASSWORD: prisma | ||
POSTGRES_DB: tests |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...node-integration-tests/suites/tracing/prisma-orm-v6/prisma/migrations/migration_lock.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
12 changes: 12 additions & 0 deletions
12
...ntegration-tests/suites/tracing/prisma-orm-v6/prisma/migrations/sentry_test/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"email" TEXT NOT NULL, | ||
"name" TEXT, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); |
15 changes: 15 additions & 0 deletions
15
dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/prisma/schema.prisma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
datasource db { | ||
url = "postgresql://prisma:prisma@localhost:5434/tests" | ||
provider = "postgresql" | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
model User { | ||
id Int @id @default(autoincrement()) | ||
createdAt DateTime @default(now()) | ||
email String @unique | ||
name String? | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: Can we add a comment here explaining what and why we are doing here? For future reference :D