From 48903af4601619d9e8b670254df7132bc5cb4872 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 16 Apr 2025 11:17:14 +0200 Subject: [PATCH 1/4] feat(node): Add Prisma ontegration by default --- packages/node/src/integrations/tracing/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/node/src/integrations/tracing/index.ts b/packages/node/src/integrations/tracing/index.ts index 2873a2643617..d31145ecca5d 100644 --- a/packages/node/src/integrations/tracing/index.ts +++ b/packages/node/src/integrations/tracing/index.ts @@ -16,6 +16,7 @@ import { instrumentMongoose, mongooseIntegration } from './mongoose'; import { instrumentMysql, mysqlIntegration } from './mysql'; import { instrumentMysql2, mysql2Integration } from './mysql2'; import { instrumentPostgres, postgresIntegration } from './postgres'; +import { prismaIntegration } from './prisma'; import { instrumentRedis, redisIntegration } from './redis'; import { instrumentTedious, tediousIntegration } from './tedious'; import { instrumentVercelAi, vercelAIIntegration } from './vercelai'; @@ -34,10 +35,7 @@ export function getAutoPerformanceIntegrations(): Integration[] { mysql2Integration(), redisIntegration(), postgresIntegration(), - // For now, we do not include prisma by default because it has ESM issues - // See https://github.com/prisma/prisma/issues/23410 - // TODO v8: Figure out a better solution for this, maybe only disable in ESM mode? - // prismaIntegration(), + prismaIntegration(), hapiIntegration(), koaIntegration(), connectIntegration(), From 9cc389c56c1d1031e94f511d2d647ba868923b8d Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 5 May 2025 10:23:10 +0200 Subject: [PATCH 2/4] Bump instrumentation --- packages/node/package.json | 2 +- yarn.lock | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/node/package.json b/packages/node/package.json index e98d8137c68f..39a8f0406629 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -95,7 +95,7 @@ "@opentelemetry/resources": "^1.30.1", "@opentelemetry/sdk-trace-base": "^1.30.1", "@opentelemetry/semantic-conventions": "^1.30.0", - "@prisma/instrumentation": "6.5.0", + "@prisma/instrumentation": "6.7.0", "@sentry/core": "9.12.0", "@sentry/opentelemetry": "9.12.0", "import-in-the-middle": "^1.13.0" diff --git a/yarn.lock b/yarn.lock index f20d8694c742..6faba643ace6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4613,14 +4613,14 @@ dependencies: sparse-bitfield "^3.0.3" -"@nestjs/common@10.4.6": - version "10.4.6" - resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-10.4.6.tgz#952e8fd0ceafeffcc4eaf47effd67fb395844ae0" - integrity sha512-KkezkZvU9poWaNq4L+lNvx+386hpOxPJkfXBBeSMrcqBOx8kVr36TGN2uYkF4Ta4zNu1KbCjmZbc0rhHSg296g== +"@nestjs/common@11.0.16": + version "11.0.16" + resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-11.0.16.tgz#b6550ac2998e9991f24a99563a93475542885ba7" + integrity sha512-agvuQ8su4aZ+PVxAmY89odG1eR97HEQvxPmTMdDqyvDWzNerl7WQhUEd+j4/UyNWcF1or1UVcrtPj52x+eUSsA== dependencies: uid "2.0.2" iterare "1.2.1" - tslib "2.7.0" + tslib "2.8.1" "@nestjs/common@^10.0.0": version "10.4.15" @@ -5869,10 +5869,10 @@ resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.28.tgz#d45e01c4a56f143ee69c54dd6b12eade9e270a73" integrity sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw== -"@prisma/instrumentation@6.5.0": - version "6.5.0" - resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-6.5.0.tgz#ce6c160365dfccbe0f4e7c57a4afc4f946fee562" - integrity sha512-morJDtFRoAp5d/KENEm+K6Y3PQcn5bCvpJ5a9y3V3DNMrNy/ZSn2zulPGj+ld+Xj2UYVoaMJ8DpBX/o6iF6OiA== +"@prisma/instrumentation@6.7.0": + version "6.7.0" + resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-6.7.0.tgz#5fd97be1f89e9d9268148424a812deaea491f80a" + integrity sha512-3NuxWlbzYNevgPZbV0ktA2z6r0bfh0g22ONTxcK09a6+6MdIPjHsYx1Hnyu4yOq+j7LmupO5J69hhuOnuvj8oQ== dependencies: "@opentelemetry/instrumentation" "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0" @@ -27039,7 +27039,6 @@ stylus@0.59.0, stylus@^0.59.0: sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills: version "3.36.0" - uid fd682f6129e507c00bb4e6319cc5d6b767e36061 resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061" dependencies: "@jridgewell/gen-mapping" "^0.3.2" From 68434a8c73bbad9fea32e5872b8fda869c5cb64f Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 5 May 2025 10:25:37 +0200 Subject: [PATCH 3/4] undo yarn lock --- yarn.lock | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6faba643ace6..f20d8694c742 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4613,14 +4613,14 @@ dependencies: sparse-bitfield "^3.0.3" -"@nestjs/common@11.0.16": - version "11.0.16" - resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-11.0.16.tgz#b6550ac2998e9991f24a99563a93475542885ba7" - integrity sha512-agvuQ8su4aZ+PVxAmY89odG1eR97HEQvxPmTMdDqyvDWzNerl7WQhUEd+j4/UyNWcF1or1UVcrtPj52x+eUSsA== +"@nestjs/common@10.4.6": + version "10.4.6" + resolved "https://registry.yarnpkg.com/@nestjs/common/-/common-10.4.6.tgz#952e8fd0ceafeffcc4eaf47effd67fb395844ae0" + integrity sha512-KkezkZvU9poWaNq4L+lNvx+386hpOxPJkfXBBeSMrcqBOx8kVr36TGN2uYkF4Ta4zNu1KbCjmZbc0rhHSg296g== dependencies: uid "2.0.2" iterare "1.2.1" - tslib "2.8.1" + tslib "2.7.0" "@nestjs/common@^10.0.0": version "10.4.15" @@ -5869,10 +5869,10 @@ resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.28.tgz#d45e01c4a56f143ee69c54dd6b12eade9e270a73" integrity sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw== -"@prisma/instrumentation@6.7.0": - version "6.7.0" - resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-6.7.0.tgz#5fd97be1f89e9d9268148424a812deaea491f80a" - integrity sha512-3NuxWlbzYNevgPZbV0ktA2z6r0bfh0g22ONTxcK09a6+6MdIPjHsYx1Hnyu4yOq+j7LmupO5J69hhuOnuvj8oQ== +"@prisma/instrumentation@6.5.0": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-6.5.0.tgz#ce6c160365dfccbe0f4e7c57a4afc4f946fee562" + integrity sha512-morJDtFRoAp5d/KENEm+K6Y3PQcn5bCvpJ5a9y3V3DNMrNy/ZSn2zulPGj+ld+Xj2UYVoaMJ8DpBX/o6iF6OiA== dependencies: "@opentelemetry/instrumentation" "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0" @@ -27039,6 +27039,7 @@ stylus@0.59.0, stylus@^0.59.0: sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills: version "3.36.0" + uid fd682f6129e507c00bb4e6319cc5d6b767e36061 resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061" dependencies: "@jridgewell/gen-mapping" "^0.3.2" From b5dfa28c47a26a8a27bd0ed29971c5e9a041c20c Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 5 May 2025 13:32:34 +0200 Subject: [PATCH 4/4] esm compat --- packages/node/src/integrations/tracing/prisma.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/node/src/integrations/tracing/prisma.ts b/packages/node/src/integrations/tracing/prisma.ts index 58c0a8019cd8..c674e0bfdfbe 100644 --- a/packages/node/src/integrations/tracing/prisma.ts +++ b/packages/node/src/integrations/tracing/prisma.ts @@ -1,6 +1,5 @@ import type { Instrumentation } from '@opentelemetry/instrumentation'; -// When importing CJS modules into an ESM module, we cannot import the named exports directly. -import * as prismaInstrumentation from '@prisma/instrumentation'; +import { PrismaInstrumentation } from '@prisma/instrumentation'; import { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core'; import { generateInstrumentOnce } from '../../otel/instrument'; import type { PrismaV5TracingHelper } from './prisma/vendor/v5-tracing-helper'; @@ -8,11 +7,6 @@ import type { PrismaV6TracingHelper } from './prisma/vendor/v6-tracing-helper'; const INTEGRATION_NAME = 'Prisma'; -const EsmInteropPrismaInstrumentation: typeof prismaInstrumentation.PrismaInstrumentation = - // @ts-expect-error We need to do the following for interop reasons - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - prismaInstrumentation.default?.PrismaInstrumentation || prismaInstrumentation.PrismaInstrumentation; - type CompatibilityLayerTraceHelper = PrismaV5TracingHelper & PrismaV6TracingHelper; function isPrismaV6TracingHelper(helper: unknown): helper is PrismaV6TracingHelper { @@ -31,7 +25,7 @@ function getPrismaTracingHelper(): unknown | undefined { return prismaTracingHelper; } -class SentryPrismaInteropInstrumentation extends EsmInteropPrismaInstrumentation { +class SentryPrismaInteropInstrumentation extends PrismaInstrumentation { public constructor() { super(); }