Skip to content

feat(server-utils)!: Start Redis spans as cache spans - #23933

Open
s1gr1d wants to merge 5 commits into
developfrom
sig/redis-span-name-cache
Open

feat(server-utils)!: Start Redis spans as cache spans#23933
s1gr1d wants to merge 5 commits into
developfrom
sig/redis-span-name-cache

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 2, 2026

Copy link
Copy Markdown
Member

With span streaming, ignoreSpans runs at span start. Redis cache spans used to start as db.query and get renamed to cache.* at response time, so a filter matching what you see in the UI never matched anything (part of #23830).

Now a command whose key matches cachePrefixes starts as a cache.* span on all four instrumentation paths. At response time we only add cache.hit/cache.item_size (as we only know it at this time). Static-lifecycle output is unchanged.

Behavior changes and limitations:

  • Failed cache commands now report as cache.* spans. They previously stayed db.query.
  • maxCacheKeyLength only applies to traceLifecycle: 'static' (added to JSDoc). Streamed span names don't need truncation.
  • Multi-key commands on node-redis >=5.12 still stay db.query: the library sanitizes keys to ? before we see them (pre-existing).

Closes #23832

@s1gr1d
s1gr1d requested review from a team as code owners September 2, 2026 12:02
@s1gr1d
s1gr1d requested review from JPeer264, Lms24 and isaacs and removed request for a team September 2, 2026 12:02
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB -4.23% -1.26 kB 🔽
@sentry/browser - with treeshaking flags 26.94 kB -3.9% -1.09 kB 🔽
@sentry/browser (incl. Tracing) 48.87 kB +3.44% +1.62 kB 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.88 kB +3.4% +1.6 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 51.8 kB -0.38% -197 B 🔽
@sentry/browser (incl. Tracing, Replay) 88.36 kB +2.05% +1.77 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.76 kB +2.32% +1.76 kB 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 93.05 kB +1.94% +1.77 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 106.02 kB +1.99% +2.06 kB 🔺
@sentry/browser (incl. Feedback) 46.06 kB -2.28% -1.07 kB 🔽
@sentry/browser (incl. sendFeedback) 33.64 kB -2.98% -1.03 kB 🔽
@sentry/browser (incl. FeedbackAsync) 38.74 kB -2.61% -1.03 kB 🔽
@sentry/browser (incl. Metrics) 29.52 kB -4.48% -1.38 kB 🔽
@sentry/browser (incl. Logs) 29.81 kB -4.29% -1.33 kB 🔽
@sentry/browser (incl. Metrics & Logs) 30.45 kB -4.3% -1.37 kB 🔽
@sentry/react 30.32 kB -4.15% -1.31 kB 🔽
@sentry/react (incl. Tracing) 51.08 kB +3.17% +1.57 kB 🔺
@sentry/vue 35.74 kB +2.35% +819 B 🔺
@sentry/vue (incl. Tracing) 51.14 kB +3.87% +1.9 kB 🔺
@sentry/svelte 28.6 kB -4.21% -1.25 kB 🔽
CDN Bundle 30.36 kB -4.75% -1.51 kB 🔽
CDN Bundle (incl. Tracing) 49.52 kB +4.17% +1.98 kB 🔺
CDN Bundle (incl. Logs, Metrics) 32.59 kB -2.46% -819 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 51.43 kB +5.07% +2.48 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.19 kB +0.61% +439 B 🔺
CDN Bundle (incl. Tracing, Replay) 87 kB +2.14% +1.82 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.88 kB +2.75% +2.38 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.93 kB +2.11% +1.92 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.83 kB +2.74% +2.52 kB 🔺
CDN Bundle - uncompressed 89.97 kB -4.92% -4.65 kB 🔽
CDN Bundle (incl. Tracing) - uncompressed 147.57 kB +3.84% +5.45 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.27 kB -3% -2.98 kB 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.26 kB +4.91% +7.16 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.43 kB +0.67% +1.49 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.07 kB +2.18% +5.69 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.74 kB +2.79% +7.4 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.77 kB +2.07% +5.69 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.43 kB +2.66% +7.4 kB 🔺
@sentry/nextjs (client) 53.7 kB +3.11% +1.62 kB 🔺
@sentry/sveltekit (client) 49.3 kB +3.35% +1.59 kB 🔺
@sentry/core/server 40.74 kB -37.82% -24.78 kB 🔽
@sentry/core/browser 13.42 kB -74.13% -38.46 kB 🔽
@sentry/node 124.47 kB +3.52% +4.23 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB added added
@sentry/node - without tracing 88.3 kB +5.51% +4.61 kB 🔺
@sentry/aws-serverless 96.66 kB +4.67% +4.31 kB 🔺
@sentry/cloudflare (withSentry) - minified 200.81 kB -8.16% -17.84 kB 🔽
@sentry/cloudflare (withSentry) 499.76 kB -7.26% -39.09 kB 🔽
@sentry/browser - with treeshaking flags tracing without tracing 26.83 kB added added
@sentry/node - without channel injection 103.75 kB added added

View base workflow run

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for tackling this so quickly!

await createTestRunner()
.withEnv({ STREAMED: 'true', IGNORE_CACHE_GET: 'true' })
.unordered()
.expect({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: we could also assert on a client report here for the ignored span(s) to make it more explicit, wdyt?

*/
export function applyCacheResponseAttributes(span: Span, response: unknown): void {
const op = spanToJSON(span).attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP];
if (op !== CACHE_GET && op !== CACHE_PUT) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

q: Do we need to worry about CACHE_REMOVE spans here? or are they not emitted for redis?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's mentioned in the JSDoc above why we we return early for deletions. For delete, we cannot set item-size or cache-hit. Both do not make sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

my bad for not reading it, sorry! and thanks!

s1gr1d and others added 3 commits September 2, 2026 16:59
Composes the start-time cache classification with develop's low-cardinality
redis db span names (#23741): at each span start site the cache name/op wins
for cache-prefixed keys, the streamed db name applies otherwise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@s1gr1d
s1gr1d enabled auto-merge (squash) September 2, 2026 15:18
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.

Start Redis cache spans right away as cache spans

3 participants