Skip to content

feat(cache): [Cache Tracing 18] Add cache.write boolean span attribute#5207

Draft
adinauer wants to merge 1 commit intoref/cache-tracing-cache-operation-keyfrom
feat/cache-tracing-cache-write
Draft

feat(cache): [Cache Tracing 18] Add cache.write boolean span attribute#5207
adinauer wants to merge 1 commit intoref/cache-tracing-cache-operation-keyfrom
feat/cache-tracing-cache-write

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 18, 2026

PR Stack (Cache Tracing)

  • #5172 — Add SentryCacheWrapper and SentryCacheManagerWrapper
  • #5173 — Add enableCacheTracing option
  • #5174 — Add BeanPostProcessor and auto-configuration
  • #5175 — Add cache tracing e2e sample
  • #5179 — Add SentryJCacheWrapper for JCache (JSR-107)
  • #5182 — Add JCache console sample
  • #5183 — Add cache tracing to all Spring Boot 4 samples
  • #5184 — Add retrieve() overrides for reactive/async cache support
  • #5190 — Port cache tracing to Spring Boot 3 Jakarta + samples
  • #5191 — Port cache tracing to Spring Boot 2 + samples
  • #5192 — Skip cache span data when child span is NoOp
  • #5201 — Add db.operation.name attribute to cache spans
  • #5202 — Instrument putIfAbsent, replace, and getAndReplace
  • #5203 — Fix cache hit detection for typed get and fix jcache docs link
  • #5204 — Use method-specific span operations for cache spans
  • #5205 — Merge startSpan helpers into shared core method
  • #5206 — Move operation attribute to centralized CACHE_OPERATION_KEY constant
  • #5207 — Add cache.write boolean span attribute
  • #5208 — Use comma-joined keys as span description for bulk JCache operations
  • #5209 — Remove _KEY suffix from cache SpanDataConvention constants
  • #5210 — Fix get(key, type) double-call in SentryCacheWrapper
  • #5212 — Fix cache evict system test to match actual span op

📜 Description

Adds a CACHE_WRITE = "cache.write" constant to SpanDataConvention and sets it on spans across all four cache wrapper implementations (spring, spring-7, spring-jakarta, jcache).

The value reflects whether the operation actually modified the cache:

  • Pure reads (get, getAll, retrieve): omitted
  • Unconditional writes (put, putAll, evict, clear, invalidate, removeAll): true
  • Conditional writes (putIfAbsent, replace, remove, getAndReplace, getAndRemove): based on return value
  • Loader-based reads (get(key, Callable), retrieve(key, Supplier)): based on whether loader was invoked
  • Opaque operations (invoke, invokeAll): omitted (can't determine if EntryProcessor wrote)

💡 Motivation and Context

Cache tracing spans currently track cache.hit for read operations, but there's no equivalent attribute indicating whether an operation actually modified the cache. Adding cache.write lets the Sentry UI show write counts/rates and helps users distinguish no-op conditional operations (e.g. putIfAbsent when key exists) from actual mutations.

💚 How did you test it?

  • Added cache.write assertions to all existing cache wrapper test classes
  • All tests pass across sentry-spring, sentry-spring-7, sentry-spring-jakarta, and sentry-jcache

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

Set cache.write on spans across all four cache wrapper implementations
to indicate whether an operation actually modified the cache. This
complements the existing cache.hit attribute for read operations.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7426ac7

@sentry
Copy link

sentry bot commented Mar 18, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK Size io.sentry.tests.size 8.34.1 (1) release Install Build

@adinauer
Copy link
Member Author

@sentry review

@adinauer
Copy link
Member Author

cursor review

Copy link

@cursor cursor bot left a comment

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.

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