Repository navigation
feat(server-utils): Record returned rows on pg and Neon query spans - #26666
Open
sentry-junior[bot] wants to merge 1 commit into
Open
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
Set db.response.returned_rows on pg query spans from the result's rowCount, falling back to rows.length. Multi-statement results are summed, streamed Query submittables report the result they end with, and cursors set nothing because they end with only the last batch. The Neon HTTP driver gets the same attribute from its rows array or fullResults result. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
javascript-sdk-gitflow
Bot
requested review from
andreiborza,
isaacs and
timfish
November 19, 2026 17:33
Contributor
size-limit report 📦Compared: 31786a6 (PR test merge using develop at 1884708) Against: 1884708 (develop) · base run #67147 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsAll optional checks were successful. 58 successful. See the run. Successful checks
|
BYK
added a commit
to getsentry/junior
that referenced
this pull request
Nov 19, 2026
Pinned pnpm patch for `@sentry/server-utils@11.14.0` that backports getsentry/sentry-javascript#26666. pg and Neon query spans now carry `db.response.returned_rows`, so a slow statement shows whether it read many rows. The patch changes the built pg and Neon integrations (ESM and CJS): - The count comes from the result's `rowCount`, falling back to `rows.length`. - Multi-statement results are summed. - A streamed `Query` reports the result it ends with. - Cursors and streams set nothing, because they end with only the last batch's count. - The Neon HTTP channel reads the rows array, the `fullResults` result, or a `transaction()` batch. Drop the patch and its `patchedDependencies` entry when Junior bumps to an SDK release that includes getsentry/sentry-javascript#26666. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A825beff139610fd6deb1d4e59cf4fb79 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A825beff139610fd6deb1d4e59cf4fb79) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A825beff139610fd6deb1d4e59cf4fb79/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
Lms24
requested changes
Nov 20, 2026
Lms24
left a comment
Member
There was a problem hiding this comment.
Let's add the attribute to sentry conventions first please. Change looks good to me otherwise.
This was referenced Nov 20, 2026
Contributor
Author
|
@Lms24 Added it to conventions in getsentry/sentry-conventions#826. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
pg query spans now set
db.response.returned_rows(OTel semconv, development status). The value is the result'srowCount, orrows.lengthwhenrowCountisn't a number. It covers single results, multi-statement results (one per statement, summed), callback and promise queries, and streamedQuerysubmittables, which report the result they end with. Nothing is set on errors or when no count is known.Neon's WebSocket driver already goes through the pg query channel. The HTTP driver (
neon()) uses its ownhttp-querychannel, so it gets the same attribute from the bare rows array, from afullResultsresult, or from atransaction()batch (summed).Why
Without a row count on DB spans you can't tell whether a slow statement read many rows or read a few badly.
Cursors and streams (
pg-cursor,pg-query-stream) are skipped on purpose: they are read in batches and end with only the last batch'srowCountand rows. Against Postgres, a 25-row cursor read in batches of 10 ends withrowCount: 5.Semantic note: pg exposes one count. For INSERT/UPDATE/DELETE without
RETURNING,rowCountis the number of affected rows, so this reports that rather than 0. The Neon HTTP driver withoutfullResultsonly gets the rows array, so the same INSERT reports 0 there. DDL reports 0.via @BYK.
--
View Session [Sentry]