Skip to content

feat(spring): [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper#5172

Draft
adinauer wants to merge 5 commits intofeat/cache-tracingfrom
feat/cache-tracing-wrappers
Draft

feat(spring): [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper#5172
adinauer wants to merge 5 commits intofeat/cache-tracingfrom
feat/cache-tracing-wrappers

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 9, 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)

📜 Description

Adds SentryCacheWrapper and SentryCacheManagerWrapper to the sentry-spring-7 module. These wrapper classes instrument Spring's Cache and CacheManager interfaces to produce cache.get, cache.put, cache.remove, and cache.flush spans per the Sentry cache module spec.

Also adds CACHE_HIT_KEY and CACHE_KEY_KEY constants to SpanDataConvention.

💚 How did you test it?

  • Unit tests for SentryCacheWrapper covering all cache operations, hit/miss detection, error handling, and span data assertions
  • Unit tests for SentryCacheManagerWrapper covering cache wrapping, null passthrough, and getCacheNames delegation

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • No breaking change or entry added to the changelog.

adinauer and others added 4 commits March 2, 2026 16:45
…eManagerWrapper

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion

- Use cache key as span description instead of cache name, matching
  the spec and other SDKs (Python, JavaScript)
- Skip instrumentation for putIfAbsent since we cannot know if a write
  actually occurred; override to bypass default get()+put() delegation
- Wrap valueLoader Callable in get(key, Callable) to detect cache
  hit/miss instead of always reporting hit=true
- Update tests to match new behavior

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

github-actions bot commented Mar 9, 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).


New Features ✨

  • (anr) Profile main thread when ANR and report ANR profiles to Sentry by markushi in #4899
  • (spring) [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper by adinauer in #5172

Bug Fixes 🐛

  • Remove the dependency on protobuf-lite for tombstones by supervacuus in #5157

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper ([#5172](https://github.com/getsentry/sentry-java/pull/5172))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 94ae0e1

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 405.20 ms 453.20 ms 48.00 ms
Size 0 B 0 B 0 B

Previous results on branch: feat/cache-tracing-wrappers

Startup times

Revision Plain With Sentry Diff
8baac33 313.15 ms 367.84 ms 54.69 ms
3e5f591 317.48 ms 356.80 ms 39.32 ms
2876c40 339.24 ms 405.65 ms 66.41 ms
4b44539 255.79 ms 300.12 ms 44.33 ms

App size

Revision Plain With Sentry Diff
8baac33 0 B 0 B 0 B
3e5f591 0 B 0 B 0 B
2876c40 1.58 MiB 2.29 MiB 723.29 KiB
4b44539 0 B 0 B 0 B

@sentry
Copy link

sentry bot commented Mar 9, 2026

Sentry Build Distribution

App Version Configuration
SDK Size 8.34.1 (1) release

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