Skip to content

ref(node): Streamline Prisma instrumentation (v6 and v7) - #21819

Merged
nicohrubec merged 10 commits into
developfrom
sig/streamline-prisma
Jun 30, 2026
Merged

ref(node): Streamline Prisma instrumentation (v6 and v7)#21819
nicohrubec merged 10 commits into
developfrom
sig/streamline-prisma

Conversation

@s1gr1d

@s1gr1ds1gr1d commented Jun 26, 2026

Copy link
Copy Markdown
Member

Streamlines the vendored Prisma instrumentation onto Sentry's span APIs (v6/v7):

  • Folds attributes previously set via the spanStart hook into span creation in the instrumentation.
  • Uses startSpanManual/startInactiveSpan from @sentry/core instead of the OTel tracer in the vendored tracing helper.
  • Removes unused code: setTracerProvider/tracerProvider and unused contract types (EngineTrace, EngineTraceEvent, LogLevel).

v5 cleanup will be done in a followup.

Part of #20744

Closes#21820

@s1gr1d
s1gr1d requested a review from a team as a code ownerJune 26, 2026 13:45
@s1gr1d
s1gr1d requested review from JPeer264, andreiborza, mydea and nicohrubec and removed request for a teamJune 26, 2026 13:45
@github-actions

github-actionsBot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.48 kB--
@sentry/browser - with treeshaking flags25.91 kB--
@sentry/browser (incl. Tracing)46 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.76 kB--
@sentry/browser (incl. Tracing, Profiling)50.79 kB--
@sentry/browser (incl. Tracing, Replay)85.25 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.84 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.95 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.61 kB--
@sentry/browser (incl. Feedback)44.66 kB--
@sentry/browser (incl. sendFeedback)32.26 kB--
@sentry/browser (incl. FeedbackAsync)37.4 kB--
@sentry/browser (incl. Metrics)28.54 kB--
@sentry/browser (incl. Logs)28.78 kB--
@sentry/browser (incl. Metrics & Logs)29.47 kB--
@sentry/react29.27 kB--
@sentry/react (incl. Tracing)48.31 kB--
@sentry/vue32.66 kB--
@sentry/vue (incl. Tracing)47.87 kB--
@sentry/svelte27.5 kB--
CDN Bundle29.89 kB--
CDN Bundle (incl. Tracing)47.94 kB--
CDN Bundle (incl. Logs, Metrics)31.44 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.29 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.77 kB--
CDN Bundle (incl. Tracing, Replay)85.45 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.72 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.24 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.49 kB--
CDN Bundle - uncompressed88.95 kB--
CDN Bundle (incl. Tracing) - uncompressed145.16 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed93.65 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed149.14 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.63 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed264.18 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed268.14 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.88 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.83 kB--
@sentry/nextjs (client)50.7 kB--
@sentry/sveltekit (client)46.4 kB--
@sentry/core/server77.67 kB--
@sentry/core/browser63.97 kB--
@sentry/node-core61.41 kB-0.01%-1 B 🔽
@sentry/node122.69 kB+0.03%+32 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.39 kB--
@sentry/node - without tracing73.13 kB--
@sentry/aws-serverless84.02 kB--
@sentry/cloudflare (withSentry) - minified180.46 kB--
@sentry/cloudflare (withSentry)446.48 kB--

View base workflow run

@nicohrubecnicohrubec self-assigned this Jun 29, 2026
Comment on lines +90 to 92
public getActiveContext(): Span | undefined {
return getActiveSpan();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird to me 😬 but I can't tell if it's ok or not. We'd need to investigate when exactly getActiveContext was called before and if it's fine receiving a span now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I can tell this should be fine, the output of getActiveContext is only used by getTraceParent which we also control

}

const context = options.context ?? _context.active();
const parentSpan = options.context ?? getActiveSpan();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, context being a span, is that right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options.context was dead it seems, so I simplified this

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f769463. Configure here.

@nicohrubec
nicohrubec merged commit f142d61 into developJun 30, 2026
1373 of 1382 checks passed
@nicohrubec
nicohrubec deleted the sig/streamline-prisma branch June 30, 2026 09:34
andreiborza added a commit that referenced this pull request Jul 6, 2026
Reworks the Prisma v5 engine-span compatibility shim off the OTel SDK
tracer's private `_idGenerator` and onto Sentry's provider-agnostic span
APIs. This is the v5 counterpart of #21819 (which streamlined v6/v7).
Engine spans are now minted via `startInactiveSpan`, reparented by id
through a bounded `LRUMap` registry plus a `pendingEngineSpans` buffer
that resolves spans Prisma dispatches out of order across batches. The
v5 integration test is re-enabled and a `BasicTracerProvider` variant is
added, so v5 is verified under both the default `SentryTracerProvider`
and the opt-in OTel `BasicTracerProvider`
(`openTelemetryBasicTracerProvider: true`).
_Root cause_: The `SentryTracerProvider` became the default tracer
provider. Its `SentryTracer` creates native Sentry spans and has no
`_idGenerator`, so the v5 shim (which hijacked that private field to
mint spans with the engine's exact ids) hit its guard, warned, and
dropped every `prisma:engine:*` span, leaving only the `prisma:client:*`
spans.
Closes: #21821
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamline @prisma/instrumentation for v6/v7

3 participants

@s1gr1d@nicohrubec@andreiborza