GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(server-utils): Extract `getSqlSpanName` for SQL span names by mydea · Pull Request #25929 · getsentry/sentry-javascript

Conversation

@mydea

@mydea mydea commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@github-actions

github-actions Bot commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mydea
mydea added this pull request to stack #25928 October 30, 2026 08:59
@mydea
mydea force-pushed the ref/sql-span-name branch 2 times, most recently from 874f60b to 2546505 Compare October 30, 2026 09:08
@mydea 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
@mydea
mydea force-pushed the ref/sql-span-name branch from 025b9b5 to 76b72ff Compare October 30, 2026 09:32
@mydea
mydea marked this pull request as ready for review October 30, 2026 09:57
@mydea
mydea requested review from a team as code owners October 30, 2026 09:57
@mydea
mydea requested review from andreiborza, chargome, isaacs and nicohrubec and removed request for a team October 30, 2026 09:57
@mydea
mydea force-pushed the ref/sql-span-name branch from 76b72ff to c960c78 Compare October 30, 2026 12:47
Base automatically changed from ref/sql-query-attributes to develop October 30, 2026 13:15
@mydea
mydea force-pushed the ref/sql-span-name branch from c960c78 to 0cc323a Compare October 30, 2026 13:16
nicohrubec
nicohrubec approved these changes Oct 30, 2026
View reviewed changes

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread packages/server-utils/src/integrations/postgres-js.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/server-utils/src/exports.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

chargome
chargome approved these changes Nov 3, 2026
View reviewed changes
mydea and others added 7 commits November 4, 2026 11:29
@mydea @claude
ref(server-utils): Extract getSqlSpanName for SQL span names
21003c6
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]>
@mydea @claude
ref(server-utils): Use the shared SQL span name fallbacks for knex
c9a35c5
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]>
@mydea @claude
ref(server-utils): Derive SQL span name fallbacks from span attributes
5d6b072
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]>
@mydea @claude
ref(server-utils): Use getSqlSpanName for postgres.js
f799455
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]>
@mydea @claude
ref(server-utils): Use getSqlSpanName for Prisma db_query spans
a27a47e
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]>
@mydea @claude
ref(server-utils): Add getLowCardinalitySqlSpanName and use it for …
643dd34
…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]>
@mydea @claude
ref(server-utils): Don't re-apply postgres.js connection attributes a…
7ef8678
…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]>
mydea and others added 3 commits November 4, 2026 11:29
@mydea @claude
ref(server-utils): Drop the postgres.js connection attributes marker
84b433d
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]>
@mydea @claude
ref(server-utils): Only export getSqlSpanName from the SQL span nam…
dcca55a
…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]>
@mydea @claude
test(node): Cover postgres.js connection attributes with multiple end…
3e5327f
…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]>
@mydea
mydea force-pushed the ref/sql-span-name branch from 0cc323a to 3e5327f Compare November 4, 2026 10:33
@mydea mydea mentioned this pull request Nov 4, 2026
ref(server-utils): Share the postgres.js query settlement logic #26094
Merged
@mydea
mydea merged commit 4d85171 into develop Nov 4, 2026
276 of 277 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mydea
mydea deleted the ref/sql-span-name branch November 4, 2026 11:53
mydea added a commit that referenced this pull request Nov 4, 2026
@mydea @claude
ref(server-utils): Share the postgres.js query settlement logic (#26094)
069f36a
**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]>
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Nov 5, 2026
publish: getsentry/[email protected] getsentry/publish#10234
Closed
51 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chargome chargome chargome approved these changes
@nicohrubec nicohrubec nicohrubec approved these changes
@isaacs isaacs Awaiting requested review from isaacs isaacs was automatically assigned from getsentry/team-javascript-sdks-server
@andreiborza andreiborza Awaiting requested review from andreiborza andreiborza was automatically assigned from getsentry/team-javascript-sdks-server

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@mydea @chargome @nicohrubec
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.