Skip to content

Commit 0b6b71f

Browse files
committed
add comment explaining what we are doing
1 parent 8033776 commit 0b6b71f

File tree

1 file changed

+6
-0
lines changed
  • packages/node/src/integrations/tracing

1 file changed

+6
-0
lines changed

packages/node/src/integrations/tracing/prisma.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
7979
) => {
8080
const tracer = trace.getTracer('prismaV5Compatibility') as TracerWithIdGenerator;
8181

82+
// Prisma v5 relies on being able to create spans with a specific span & trace ID
83+
// this is no longer possible in OTEL v2, there is no public API to do this anymore
84+
// So in order to kind of hack this possibility, we rely on the internal `_idGenerator` property
85+
// This is used to generate the random IDs, and we overwrite this temporarily to generate static IDs
86+
// This is flawed and may not work, e.g. if the code is bundled and the private property is renamed
87+
// in such cases, these spans will not be captured and some Prisma spans will be missing
8288
const initialIdGenerator = tracer._idGenerator;
8389

8490
if (!initialIdGenerator) {

0 commit comments

Comments
 (0)