GeezerVison is showing github.com — feat(server-utils): Extract `getSqlSpanName` for SQL span names by mydea · Pull Request #25929 · getsentry/sentry-javascript
Conversation
mydea
commented
Oct 30, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
TLDR: This PR introduces a helper to build db span names based on semantic conventions. This should make it more consistent and easier to use this in the future.
Why: We used to repeat more or less the same code in various places for building span names. Most places have a branch for legacy high-cardinality names (transactions) and low-cardinality names (streamed spans). New utilities help with that. Note that new integrations (like neon) should use the low-cardinality version only.
How to review: getSqlSpanName in utils/sql.ts, then skim the callsites, which now build their attributes before naming the span. Behavior changes, all limited to edge cases or improvements:
- Knex drops its custom fallbacks (operation/table/database). They only applied to queries without SQL, which knex practically never produces, and the operation and table stay on the span as attributes.
- Nuxt's streamed fallback now uses
db.system.name before 'Database operation'.
- postgres.js (diagnostics channel) sets its resolved connection attributes at span start, so the namespace is available for the name.
- Prisma only routes
db_query spans through the helper; every other Prisma span keeps its own name, even when it carries db attributes (e.g. v5's prisma:engine:connection has db.system). For db_query spans:
- Streamed names are unchanged (
db.query.summary first).
- Non-streamed names on Prisma 5 now use the sanitized
db.query.text (backfilled in feat(server-utils): Move to new getSqlQueryAttributes helper for consistency #25927) instead of the raw db.statement, so literals no longer end up in span names, e.g. … WHERE 1=1 … becomes … WHERE ?=? …. Prisma 6+ already uses Prisma's own db.query.text, so nothing changes there.
- A streamed
db_query span with no SQL at all would now fall back to db.namespace/db.system.name before the Prisma span name. Prisma doesn't emit query spans without SQL in practice.
Unsure about: Tedious keeps its own names on purpose (see the comment there): bulk loads and procedure calls have no statement, and operation-based names say more than the namespace.
Stacked on #25927.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
size-limit report 📦
Compared: 2ad1ebc (PR test merge using develop at 2619fa4)
Against: 2619fa4 (develop) · base run #64952
✅ Baseline matches: this diff contains only this PR's changes.
| Path |
Size |
% Change |
Change |
| @sentry/browser |
30.4 kB |
- |
- |
| @sentry/browser - with treeshaking flags |
28.54 kB |
- |
- |
| @sentry/browser - with treeshaking flags tracing without tracing |
28.43 kB |
- |
- |
| @sentry/browser (incl. Tracing) |
52.72 kB |
- |
- |
| @sentry/browser (incl. Tracing + Span Streaming) |
52.72 kB |
- |
- |
| @sentry/browser (incl. Tracing, Profiling) |
55.69 kB |
- |
- |
| @sentry/browser (incl. Tracing, Replay) |
93.02 kB |
- |
- |
| @sentry/browser (incl. Tracing, Replay) - with treeshaking flags |
81.61 kB |
- |
- |
| @sentry/browser (incl. Tracing, Replay with Canvas) |
97.76 kB |
- |
- |
| @sentry/browser (incl. Tracing, Replay, Feedback) |
110.75 kB |
- |
- |
| @sentry/browser (incl. Feedback) |
47.98 kB |
- |
- |
| @sentry/browser (incl. sendFeedback) |
35.5 kB |
- |
- |
| @sentry/browser (incl. FeedbackAsync) |
40.61 kB |
- |
- |
| @sentry/browser (incl. Metrics) |
31.44 kB |
- |
- |
| @sentry/browser (incl. Logs) |
31.73 kB |
- |
- |
| @sentry/browser (incl. Metrics & Logs) |
32.45 kB |
- |
- |
| @sentry/react |
32.29 kB |
- |
- |
| @sentry/react (incl. Tracing) |
55.09 kB |
- |
- |
| @sentry/vue |
38.67 kB |
- |
- |
| @sentry/vue (incl. Tracing) |
55.73 kB |
- |
- |
| @sentry/svelte |
30.43 kB |
- |
- |
| @sentry/remix (Remix 3 client bundle) |
57.8 kB |
- |
- |
| CDN Bundle |
32.19 kB |
- |
- |
| CDN Bundle (incl. Tracing) |
53.24 kB |
- |
- |
| CDN Bundle (incl. Logs, Metrics) |
34.47 kB |
- |
- |
| CDN Bundle (incl. Tracing, Logs, Metrics) |
55.19 kB |
- |
- |
| CDN Bundle (incl. Replay, Logs, Metrics) |
75.88 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay) |
91.46 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Logs, Metrics) |
93.39 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Feedback) |
97.56 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) |
99.56 kB |
- |
- |
| CDN Bundle - uncompressed |
94.67 kB |
- |
- |
| CDN Bundle (incl. Tracing) - uncompressed |
157.63 kB |
- |
- |
| CDN Bundle (incl. Logs, Metrics) - uncompressed |
101.14 kB |
- |
- |
| CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed |
163.37 kB |
- |
- |
| CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed |
232.71 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay) - uncompressed |
279.32 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed |
285.05 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed |
293.03 kB |
- |
- |
| CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed |
298.74 kB |
- |
- |
| @sentry/nextjs (client) |
58.04 kB |
- |
- |
| @sentry/sveltekit (client) |
53.23 kB |
- |
- |
| @sentry/core/server |
44.25 kB |
- |
- |
| @sentry/core/browser |
13.93 kB |
- |
- |
| @sentry/node |
155.68 kB |
-0.07% |
-103 B 🔽 |
| @sentry/node/import (ESM hook with diagnostics-channel injection) |
82.26 kB |
- |
- |
| @sentry/node - without tracing |
96.9 kB |
+0.02% |
+16 B 🔺 |
| @sentry/node - without channel injection |
136 kB |
-0.08% |
-99 B 🔽 |
| @sentry/aws-serverless |
105.11 kB |
+0.02% |
+21 B 🔺 |
| @sentry/cloudflare (withSentry) - minified |
200.67 kB |
- |
- |
| @sentry/cloudflare (withSentry) |
499.05 kB |
- |
- |
| @sentry/nextjs/cloudflare (withSentry) - minified |
221.21 kB |
- |
- |
View base workflow run
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Optional E2E tests
Some optional checks were not successful. They do not block the merge. 2 not successful, 50 successful. See the run.
|
Check |
Status |
|
| ❌ |
CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) |
Failing after 32s |
Details |
| ❌ |
CI: Optional E2E Tests / E2E nuxt-5 Test (optional) |
Failing after 2m |
Details |
Successful checks
|
Check |
Status |
|
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) |
Successful in 20s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) |
Successful in 26s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-flue Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E astro-7-static Test (optional) |
Successful in 57s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-pi-durable Test (optional) |
Successful in 25s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) |
Successful in 2m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) |
Successful in 55s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E deno (latest) Test (optional) |
Successful in 55s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) |
Successful in 24s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) |
Successful in 49s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) |
Successful in 25s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) |
Successful in 21s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-think Test (optional) |
Successful in 44s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) |
Successful in 2m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) |
Successful in 29s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) |
Successful in 2m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E solidstart-2 Test (optional) |
Successful in 46s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) |
Successful in 31s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) |
Successful in 40s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) |
Successful in 37s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) |
Successful in 35s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) |
Successful in 2m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-mastra Test (optional) |
Successful in 52s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) |
Successful in 2m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E astro-7 Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) |
Successful in 22s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) |
Successful in 19s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) |
Successful in 24s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-eve Test (optional) |
Successful in 59s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) |
Successful in 33s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) |
Successful in 33s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) |
Successful in 45s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) |
Successful in 48s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) |
Successful in 46s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) |
Successful in 23s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) |
Successful in 49s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) |
Successful in 57s |
Details |
| ✅ |
CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) |
Successful in 1m |
Details |
| ✅ |
CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) |
Successful in 20s |
Details |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
mydea
changed the title
ref(server-utils): Extract getSqlSpanName for SQL span names
feat(server-utils): Extract getSqlSpanName for SQL span names
Oct 30, 2026
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.
good cleanup and the span names changes seem alright to me
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Every SQL integration picked the span name the same way: the query
summary when spans are streamed, the sanitized statement otherwise, each
with an integration-specific fallback. `getSqlSpanName` takes the query
attributes and both fallbacks, and is used by mysql, mysql2, pg, knex
and the Nuxt db0 integration.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Knex built its fallback span names from the operation, table and
database, but those only apply when a query has no SQL, which knex
practically never produces. Use the database namespace or system like
the other SQL integrations instead; the operation and table stay on the
span as `db.operation.name` and `db.sql.table`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With knex on the shared fallbacks, every SQL integration fell back to
the database namespace and then the db system when streaming, both of
which they already set as span attributes. `getSqlSpanName` now reads
those from the span attributes and only takes the integration's static
fallback name.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both postgres.js integrations followed the shared naming pattern by
hand. The diagnostics-channel one now puts the resolved connection
attributes on the span up front, so the namespace is there when naming.
Tedious keeps its own names: bulk loads and procedure calls carry no
statement, and the operation-based names say more than the namespace.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only `db_query` spans go through the shared helper; other Prisma spans
keep their own name even when they carry db attributes. Non-streamed
Prisma 5 query spans are now named after the sanitized `db.query.text`
rather than the raw `db.statement`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…neon
`getSqlSpanName` only switches on span streaming because existing
integrations keep their statement-based names for static spans. New
integrations should always use low-cardinality names, so that half is
now its own helper, which neon (always low-cardinality) uses.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t span start
The resolved connection attributes are already passed to the span when it
is created, as naming needs the namespace up front, so setting them again
right after was redundant.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A query reaches only one of the `execute` and `connect` channels with a
connection, so nothing is left for the marker to guard now that span start
no longer sets it. Also simplifies `deferSpanEnd` and inlines two small
helpers that were left with a single purpose.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e helpers
`getLowCardinalitySqlSpanName` and `SqlQueryAttributes` are only used inside
`@sentry/server-utils`, whereas Nuxt needs `getSqlSpanName`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…points
Existing scenarios use a single endpoint, which the integration resolves
when the span starts, so nothing exercised the `execute` and `connect`
channels that attach the attributes when several endpoints are known.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
mydea
added a commit
that referenced
this pull request
Nov 4, 2026
**Why:** The postgres.js integration and the portable
`instrumentPostgresJsSql` wrapper each had their own copy of the logic
that ends a span when a query settles. This moves it into one helper and
gives it direct unit tests, which it didn't have before.
**How to review:** Start with `_wrapQuerySettlement` in
`postgresjs-wrapper.ts`, which is the integration's existing function
plus an `onSettle` callback for its `SPAN_ENDED` flag. The integration
side should behave the same. The wrapper changes slightly: it uses plain
functions instead of Proxies (the callbacks have no properties to
forward), a missing callback no longer throws, and its debug messages
use the `[instrumentation:postgresjs]` prefix.
**Unsure about:** No integration or e2e test calls
`instrumentPostgresJsSql`, so the wrapper's side is only covered by unit
tests.
Stacked on #25929.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|