Skip to content

feat(server-utils): Move to new getSqlQueryAttributes helper for consistency - #25927

Merged
mydea merged 3 commits into
feat/db-operation-namefrom
ref/sql-query-attributes
Oct 30, 2026
Merged

mydea merged 3 commits into
feat/db-operation-namefrom
ref/sql-query-attributes

Conversation

@mydea

@mydea mydea commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Why: sanitizeSqlQueryWithSummary grew a third value with db.operation.name, and every SQL integration copied the result into the same three attributes by hand. getSqlQueryAttributes returns them keyed by attribute name, so integrations spread it and the keys can't drift. The mysql2 diagnostics-channel subscriber and postgres.js drop their own operation regexes for the shared helper, so their db.operation.name keeps the statement's case and resolves CTEs like the other integrations (postgres.js still prefers the server-reported command once a query succeeds). postgres.js also no longer reports the sanitizer's Unknown SQL Query placeholder as db.query.text when there is no query; its public requestHook gets '' in that case.

How to review: Start with utils/sql.ts, then the Prisma tracing helper. Prisma keeps its own db.query.text/db.operation.name and only falls back to ours; db.query.summary is always ours, so the streamed span name stays dialect-aware across Prisma versions. Prisma 5 only reports db.statement, so its spans now also get a sanitized db.query.text (see the v5 test). Tedious clears the summary and operation name for procedure calls, as before.

Unsure about: @sentry/server-utils exports the renamed helper, but the package is internal (no SemVer guarantee) and Nuxt pins it exactly, so I didn't keep an alias.

Stacked on #25850.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 173afee (PR test merge using develop at 90450a6)

Against: 2f5a2f9 (develop) · base run #64409

⚠️ Baseline mismatch: 4 develop commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once develop's baseline build for 90450a6 finishes.

Path Size % Change Change
@sentry/browser 30.39 kB - -
@sentry/browser - with treeshaking flags 28.53 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.42 kB - -
@sentry/browser (incl. Tracing) 52.7 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.71 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.68 kB - -
@sentry/browser (incl. Tracing, Replay) 93.01 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.75 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.74 kB - -
@sentry/browser (incl. Feedback) 47.97 kB - -
@sentry/browser (incl. sendFeedback) 35.49 kB - -
@sentry/browser (incl. FeedbackAsync) 40.6 kB - -
@sentry/browser (incl. Metrics) 31.42 kB - -
@sentry/browser (incl. Logs) 31.72 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.27 kB - -
@sentry/react (incl. Tracing) 55.07 kB - -
@sentry/vue 38.66 kB - -
@sentry/vue (incl. Tracing) 55.72 kB - -
@sentry/svelte 30.42 kB - -
@sentry/remix (Remix 3 client bundle) 57.79 kB - -
CDN Bundle 32.18 kB - -
CDN Bundle (incl. Tracing) 53.23 kB - -
CDN Bundle (incl. Logs, Metrics) 34.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.17 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.86 kB - -
CDN Bundle (incl. Tracing, Replay) 91.44 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.56 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.55 kB - -
CDN Bundle - uncompressed 94.62 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.58 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.09 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.31 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.65 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 284.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.69 kB - -
@sentry/nextjs (client) 57.87 kB - -
@sentry/sveltekit (client) 53.22 kB - -
@sentry/core/server 44.24 kB - -
@sentry/core/browser 13.93 kB - -
@sentry/node 154.94 kB +0.04% +59 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.08 kB - -
@sentry/node - without tracing 96.22 kB +0.03% +20 B 🔺
@sentry/node - without channel injection 135.33 kB +0.02% +25 B 🔺
@sentry/aws-serverless 104.42 kB +0.03% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 197.91 kB +0.02% +27 B 🔺
@sentry/cloudflare (withSentry) 491.89 kB +0.01% +23 B 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 218.34 kB +0.02% +27 B 🔺

View base workflow run

@cursor cursor Bot 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 1 potential issue.

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 dd6c217. Configure here.

@github-actions

github-actions Bot commented Oct 30, 2026 •

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 31s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 2m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 23s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think 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 debug-id-sourcemaps Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 17s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 19s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 21s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 18s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 46s Details

@mydea mydea changed the title ref(server-utils): Key SQL query helper result by attribute name feat(server-utils): Move to new getSqlQueryAttributes helper for consistency Oct 30, 2026
@mydea
mydea marked this pull request as ready for review October 30, 2026 09:22
@mydea
mydea requested review from a team as code owners October 30, 2026 09:22
@mydea
mydea requested review from andreiborza, chargome, isaacs and nicohrubec and removed request for a team October 30, 2026 09:22
@mydea
mydea force-pushed the ref/sql-query-attributes branch from 0abb0e0 to 1b427a1 Compare October 30, 2026 09:32

@nicohrubec nicohrubec left a comment

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.

nice cleanup

mydea and others added 3 commits October 30, 2026 13:45
`sanitizeSqlQueryWithSummary` is now `getSqlQueryAttributes` and returns
`db.query.text`, `db.query.summary` and `db.operation.name` keyed by
their attribute names, so integrations spread it into span attributes.

The mysql2 diagnostics-channel subscriber and the Prisma tracing helper
now use it too. Prisma 5, which only reports `db.statement`, gains a
sanitized `db.query.text`; Prisma's own query text and operation name
are kept, while the summary is always derived by the SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e keys

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dious

Both still sanitized and summarized queries by hand. postgres.js
reported the sanitizer's `Unknown SQL Query` placeholder as
`db.query.text` when there was no query, and derived the fallback
`db.operation.name` from its own regex of seven keywords; the server's
reported command still takes precedence once a query succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea
mydea force-pushed the ref/sql-query-attributes branch from 1b427a1 to 2067f0d Compare October 30, 2026 12:45
@mydea
mydea merged commit 7aca628 into develop Oct 30, 2026
553 of 567 checks passed
@mydea
mydea deleted the ref/sql-query-attributes branch October 30, 2026 13:15
Sign up for free to 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.

2 participants