You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(node): Capture Prisma v5 engine spans under the SentryTracerProvider
Prisma v5 engine spans (`prisma:engine:*`, which carry the SQL `db.statement`)
were minted by hijacking the OTel SDK tracer's private `_idGenerator`. The
SentryTracerProvider's tracer has no `_idGenerator`, so the shim bailed and
dropped every engine span, leaving only the `prisma:client:*` spans.
Replace the hack with a span registry: client spans register by their span id
on `spanStart`, and each v5 engine span is created under the parent it
references by id via `startInactiveSpan`. Engine spans whose parent hasn't been
seen yet wait in a pending buffer until a later batch registers it, reproducing
the flat `parent_span_id` regrouping the OTel SDK exporter used to do.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@@ -73,87 +125,23 @@ class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
73
125
super.enable();
74
126
75
127
// The PrismaIntegration (super class) defines a global variable `global["PRISMA_INSTRUMENTATION"]` when `enable()` is called. This global variable holds a "TracingHelper" which Prisma uses internally to create tracing data. It's their way of not depending on OTEL with their main package. The sucky thing is, prisma broke the interface of the tracing helper with the v6 major update. This means that if you use Prisma 5 with the v6 instrumentation (or vice versa) Prisma just blows up, because tries to call methods on the helper that no longer exist.
76
-
// Because we actually want to use the v6 instrumentation and not blow up in Prisma 5 user's faces, what we're doing here is backfilling the v5 method (`createEngineSpan`) with a noop so that no longer crashes when it attempts to call that function.
128
+
// Because we actually want to use the v6 instrumentation and not blow up in Prisma 5 user's faces, what we're doing here is backfilling the v5-only method (`createEngineSpan`) so it routes through the v6/v7 helper instead of crashing.
0 commit comments