Skip to content

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

Merged
adinauer merged 2 commits intofeat/cache-tracingfrom
feat/cache-tracing-wrappers
Mar 5, 2026
Merged

feat(spring): [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper#5137
adinauer merged 2 commits intofeat/cache-tracingfrom
feat/cache-tracing-wrappers

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 2, 2026

📜 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.

💡 Motivation and Context

Closes partially #4120

Other Sentry SDKs (Python, JavaScript) already support cache instrumentation. This is the first PR in a 3-PR stack to add cache tracing support to the Java SDK for Spring Boot 4.

💚 How did you test it?

  • Unit tests for SentryCacheWrapper covering all cache.get/cache.put/cache.remove/cache.flush 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.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • No breaking change or entry added to the changelog.

🔮 Next steps

  • PR 2: Add enableCacheTracing option to SentryOptions/ExternalOptions
  • PR 3: Add BeanPostProcessor and Spring Boot 4 auto-configuration

…eManagerWrapper

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

github-actions bot commented Mar 2, 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 ✨

  • (spring) [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper by adinauer in #5137

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 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 ([#5137](https://github.com/getsentry/sentry-java/pull/5137))

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 6e4ede5

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 317.48 ms 356.80 ms 39.32 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 374.71 ms 455.18 ms 80.47 ms
22f4345 314.79 ms 375.02 ms 60.23 ms
91bb874 311.00 ms 363.47 ms 52.47 ms
dba088c 328.51 ms 423.79 ms 95.28 ms
5b66efd 308.67 ms 363.85 ms 55.18 ms
96eeafa 361.43 ms 455.07 ms 93.63 ms
2124a46 319.19 ms 415.04 ms 95.85 ms
d15471f 379.40 ms 470.76 ms 91.36 ms
bbc35bb 324.88 ms 425.73 ms 100.85 ms
d15471f 304.55 ms 408.43 ms 103.87 ms

App size

Revision Plain With Sentry Diff
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
22f4345 1.58 MiB 2.29 MiB 719.83 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
5b66efd 1.58 MiB 2.13 MiB 559.07 KiB
96eeafa 1.58 MiB 2.19 MiB 620.21 KiB
2124a46 1.58 MiB 2.12 MiB 551.51 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB

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

Startup times

Revision Plain With Sentry Diff
2876c40 339.24 ms 405.65 ms 66.41 ms

App size

Revision Plain With Sentry Diff
2876c40 1.58 MiB 2.29 MiB 723.29 KiB

@adinauer
Copy link
Member Author

adinauer commented Mar 3, 2026

PR Stack (Cache Tracing)

  • #5161Collection PR (full diff → main)
  • #5137 — Add SentryCacheWrapper and SentryCacheManagerWrapper
  • #5141 — Add enableCacheTracing option
  • #5142 — Add BeanPostProcessor and auto-configuration

@adinauer adinauer changed the base branch from main to feat/cache-tracing March 5, 2026 14:05
@adinauer adinauer merged commit 8ef6ac5 into feat/cache-tracing Mar 5, 2026
63 of 65 checks passed
@adinauer adinauer deleted the feat/cache-tracing-wrappers branch March 5, 2026 14:07
@adinauer adinauer restored the feat/cache-tracing-wrappers branch March 5, 2026 14:13
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