Skip to content

feat(server-utils)!: Emit low cardinality mysql db span names - #23601

Draft
Lms24 wants to merge 1 commit into
developfrom
lms/feat-server-utils-low-card-db-span-names2
Draft

feat(server-utils)!: Emit low cardinality mysql db span names#23601
Lms24 wants to merge 1 commit into
developfrom
lms/feat-server-utils-low-card-db-span-names2

Conversation

@Lms24

@Lms24 Lms24 commented Aug 25, 2026

Copy link
Copy Markdown
Member

With span streaming enabled:

  • mysql and mysql2 query spans are named after db.query.summary
  • e.g. SELECT solution FROM maths becomes SELECT maths
  • falls back to db.namespace, then db.system.name
  • new db.query.summary attribute, set in both trace lifecycles
  • statement is sanitized before summarizing, so literals cannot leak
  • covers both mysql2 paths, so names match across driver versions
  • traceLifecycle: 'static' keeps the existing names

Refs #23523

With span streaming, `mysql` and `mysql2` query spans are named after their
`db.query.summary` (`SELECT users`) instead of the full SQL statement, and
report that summary as a new `db.query.summary` attribute. Both mysql2 paths
(the orchestrion channels below 3.20.0 and the native diagnostics channels from
3.20.0 on) are covered, so the name does not depend on the driver version.

The statement is sanitized before it is summarized, so a string literal
containing `from`/`join` cannot leak a value into the name.

`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 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 f7c6bc0. Configure here.

[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_MYSQL,
[DB_QUERY_TEXT]: queryText,
[DB_QUERY_SUMMARY]: querySummary,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MySQL escapes leak into summaries

Medium Severity

Summaries are built after _INTERNAL_sanitizeSqlQuery, which only treats doubled quotes ('') as escaped string delimiters. mysql2's query channel inlines values with MySQL backslash escapes (\'), so a literal that contains a quote plus FROM/JOIN is only partially stripped and can still land in db.query.summary and the streamed span name.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f7c6bc0. 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.52 kB +0.79% +957 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 87.46 kB +0.03% +24 B 🔺
@sentry/aws-serverless 95.85 kB +0.03% +24 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