Skip to content

ref(server-utils): Move postgres.js instrumentation and SQL utils out of core - #23828

Open
mydea wants to merge 1 commit into
developfrom
fn/move-postgresjs-to-server-utils
Open

ref(server-utils): Move postgres.js instrumentation and SQL utils out of core#23828
mydea wants to merge 1 commit into
developfrom
fn/move-postgresjs-to-server-utils

Conversation

@mydea

@mydea mydea commented Sep 1, 2026

Copy link
Copy Markdown
Member

Moves the postgres.js SQL instrumentation and the shared SQL query utils out of @sentry/core/server into @sentry/server-utils, and drops the _INTERNAL_ prefix they carried on the core entrypoint.

Moved to @sentry/server-utils:

  • instrumentPostgresJsSql (+ its internal helpers)
  • getSqlQuerySummary, sanitizeSqlQuery, SqlDialect, PostgresConnectionContext

Why they move together: utils/sql was only consumed inside core by integrations/postgresjs, so neither had an internal-to-core dependency blocking the move. postgresjs only imports the public @sentry/core API (plus server-utils' own debug-build/utils/sql), so nothing had to be promoted to core's public surface.

API shape:

  • The public helpers keep clean names (_INTERNAL_ prefix dropped). @sentry/cloudflare and @sentry/deno re-export instrumentPostgresJsSql under the same name and @sentry/cloudflare uses getSqlQuerySummary/sanitizeSqlQuery internally, so there is no user-facing change.
  • The postgres-specific helpers (_reconstructQuery, _buildConnectionContext, _getConnectionAttributes, _getOperationName) were only used by server-utils' own postgres-js integration, so they are now plain module-relative imports rather than exported API.

Tests for utils/sql and postgresjs were relocated into @sentry/server-utils and their spies retargeted to the public @sentry/core namespace.

… of core

Moves the postgres.js SQL instrumentation (`instrumentPostgresJsSql` and its
helpers) and the shared SQL query utils (`getSqlQuerySummary`, `sanitizeSqlQuery`,
`SqlDialect`) out of `@sentry/core/server` into `@sentry/server-utils`, and drops
the `_INTERNAL_` prefix these carried on the core entrypoint.

`utils/sql` was only consumed inside core by `integrations/postgresjs`, so the two
move together. The postgres-specific helpers (`_reconstructQuery`,
`_buildConnectionContext`, `_getConnectionAttributes`, `_getOperationName`) were
only ever used by server-utils' own `postgres-js` integration, so they are now
plain relative imports rather than re-exported API. `instrumentPostgresJsSql` and
the SQL summary/sanitize utils stay public because `@sentry/cloudflare` and
`@sentry/deno` consume them — those keep re-exporting `instrumentPostgresJsSql`
under the same name, so there is no user-facing change.

`postgresjs` only depended on the public `@sentry/core` API (plus server-utils'
own `debug-build` and `utils/sql`), so nothing had to be promoted to core's
public surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.56 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.86 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.87 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.79 kB - -
@sentry/browser (incl. Tracing, Replay) 88.35 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.75 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.04 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106 kB - -
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.62 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 51.06 kB - -
@sentry/vue 35.73 kB - -
@sentry/vue (incl. Tracing) 51.13 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.35 kB - -
CDN Bundle (incl. Tracing) 49.5 kB - -
CDN Bundle (incl. Logs, Metrics) 32.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.41 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB - -
CDN Bundle (incl. Tracing, Replay) 87 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.83 kB - -
CDN Bundle - uncompressed 89.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.56 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.25 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.05 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.73 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.75 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.42 kB - -
@sentry/nextjs (client) 53.68 kB - -
@sentry/sveltekit (client) 49.29 kB - -
@sentry/core/server 38.27 kB -6.03% -2.45 kB 🔽
@sentry/core/browser 13.42 kB - -
@sentry/node 123.83 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.4 kB - -
@sentry/node - without tracing 88.13 kB +0.03% +25 B 🔺
@sentry/node - without channel injection 103.26 kB +0.02% +18 B 🔺
@sentry/aws-serverless 96.48 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 201.21 kB - -
@sentry/cloudflare (withSentry) 500.7 kB +0.01% +8 B 🔺

View base workflow run

@mydea
mydea marked this pull request as ready for review September 1, 2026 11:57
@mydea
mydea requested review from a team as code owners September 1, 2026 11:57
@mydea
mydea requested review from JPeer264 and isaacs and removed request for a team September 1, 2026 11:57
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.

1 participant