Skip to content

feat(server-utils): Emit low cardinality knex, tedious and prisma db span names - #23602

Draft
Lms24 wants to merge 5 commits into
developfrom
lms/feat-server-utils-low-card-db-span-names3
Draft

feat(server-utils): Emit low cardinality knex, tedious and prisma db span names#23602
Lms24 wants to merge 5 commits into
developfrom
lms/feat-server-utils-low-card-db-span-names3

Conversation

@Lms24

@Lms24 Lms24 commented Aug 25, 2026

Copy link
Copy Markdown
Member

With span streaming enabled:

  • knex, prisma and tedious spans are named after db.query.summary, with fallbacks according to lower prio sentry convention name templates
  • traceLifecycle: 'static' keeps the existing names

Also discovered some bugs along the way that should be addressed afterwards but don't belong into this PR:

Refs #23523

… span names

With span streaming, these three name their query spans from the span name
conventions instead of the SQL statement. They are grouped because each needs a
different fallback: knex drops to its existing `{operation} {namespace}.{table}`,
tedious has no statement to summarize and keeps `getSpanName`, and prisma resolves
its statement from either `db.statement` or `db.query.text` depending on version.

knex and prisma also report the new `db.query.summary` attribute.

`traceLifecycle: 'static'` keeps the existing names.

Refs #23523
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
// `from`/`join` can't leak a value into the summary.
const querySummary = dbStatement
? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(dbStatement))
: undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truncation breaks summary sanitization

Medium Severity

Knex truncates the SQL with truncate before _INTERNAL_sanitizeSqlQuery and _INTERNAL_getSqlQuerySummary. Truncation can cut an open string literal, so the sanitize pass misses it and FROM/JOIN tokens inside that literal can land in db.query.summary and the streamed span name, which is the leak this sanitization step is meant to block.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c57ede4. Configure here.

Comment thread packages/server-utils/src/integrations/knex.ts Outdated
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.57 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.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.56 kB - -
@sentry/browser (incl. Tracing, Replay) 88.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.51 kB - -
@sentry/browser (incl. Feedback) 45.79 kB - -
@sentry/browser (incl. sendFeedback) 33.35 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 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.31 kB - -
@sentry/react (incl. Tracing) 50.84 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.88 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.12 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.01 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.62 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.52 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.33 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.68 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.08 kB - -
@sentry/core/server 65.15 kB -0.23% -149 B 🔽
@sentry/core/browser 52.37 kB - -
@sentry/node 122.8 kB +0.27% +320 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.73 kB +0.11% +93 B 🔺
@sentry/node - without channel injection 102.46 kB +0.3% +298 B 🔺
@sentry/aws-serverless 95.88 kB +0.1% +91 B 🔺
@sentry/cloudflare (withSentry) - minified 199.61 kB - -
@sentry/cloudflare (withSentry) 495.94 kB - -

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.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 442fabe. Configure here.

Comment thread dev-packages/node-integration-tests/suites/tracing/tedious/test.ts
@Lms24 Lms24 self-assigned this Aug 27, 2026
@Lms24 Lms24 changed the title feat(server-utils)!: Emit low cardinality knex, tedious and prisma db span names feat(server-utils): Emit low cardinality knex, tedious and prisma db span names Aug 27, 2026
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