Skip to content

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

Draft
Lms24 wants to merge 1 commit 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 1 commit 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 and prisma spans are named after db.query.summary
  • knex falls back to its existing {operation} {namespace}.{table}
  • tedious has no statement, so keeps {operation} {namespace}
  • prisma spans without SQL keep their engine span name
  • new db.query.summary attribute on knex and prisma
  • statement is sanitized before summarizing, so literals cannot leak
  • traceLifecycle: 'static' keeps the existing names

Grouped because each needs a different per-driver fallback.

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>

@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 2 potential issues.

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

// `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.


return startInactiveSpan({
name: dbStatement ?? getName(name, operation, table) ?? 'knex.query',
name: streamedName ?? dbStatement ?? getName(name, operation, table) ?? 'knex.query',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Feat PR missing integration tests

Medium Severity

Flagged because the PR review guidelines ask feat PRs to include at least one integration or E2E test. This change adds streamed low-cardinality names and db.query.summary for knex, prisma, and tedious, but the commit has no tests that assert the new naming or attributes under traceLifecycle: 'stream' versus static.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit c57ede4. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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.55 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.57 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.47 kB - -
@sentry/browser (incl. Tracing, Replay) 88 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.44 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.69 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.41 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.47 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.33 kB - -
@sentry/react (incl. Tracing) 50.76 kB - -
@sentry/vue 35.64 kB - -
@sentry/vue (incl. Tracing) 50.78 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 49.07 kB - -
CDN Bundle (incl. Logs, Metrics) 32.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.94 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.96 kB - -
CDN Bundle (incl. Tracing, Replay) 86.57 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.27 kB - -
CDN Bundle - uncompressed 89.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.74 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.3 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.14 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.82 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.84 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.51 kB - -
@sentry/nextjs (client) 53.27 kB - -
@sentry/sveltekit (client) 48.97 kB - -
@sentry/core/server 65.11 kB - -
@sentry/core/browser 52.27 kB - -
@sentry/node 122.47 kB +0.75% +907 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 87.46 kB +0.03% +22 B 🔺
@sentry/aws-serverless 95.85 kB +0.03% +23 B 🔺
@sentry/cloudflare (withSentry) - minified 199.28 kB - -
@sentry/cloudflare (withSentry) 495.43 kB - -

View base workflow run

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