Skip to content

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

Draft
adinauer wants to merge 1 commit intomainfrom
feat/cache-tracing-wrappers
Draft

feat(spring): [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper#5137
adinauer wants to merge 1 commit intomainfrom
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 ✨

  • (otel) Create sentry-opentelemetry-otlp module for combining OpenTelemetry SDK OTLP export with Sentry SDK by adinauer in #5100
  • (screenshot) Add screenshot masking using view hierarchy by romtsn in #5077
  • (spring) [Cache Tracing 1] Add SentryCacheWrapper and SentryCacheManagerWrapper by adinauer in #5137

Bug Fixes 🐛

  • Trim DSN string before URI parsing by adinauer in #5113
  • Safe unregister SystemEventsBroadcastReceiver by kollesnica1337 in #5106

Internal Changes 🔧

Deps

  • Bump getsentry/craft from 2.21.7 to 2.23.1 by dependabot in #5129
  • Update Native SDK to v0.13.1 by github-actions in #5104
  • Bump actions/upload-artifact from 6 to 7 by dependabot in #5130
  • Bump actions/download-artifact from 7 to 8 by dependabot in #5132
  • Bump gradle/actions from 5.0.1 to 5.0.2 by dependabot in #5131
  • Bump github/codeql-action from 4.32.2 to 4.32.4 by dependabot in #5109
  • Bump getsentry/craft from 2.21.2 to 2.21.7 by dependabot in #5110

🤖 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 8925435

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 339.24 ms 405.65 ms 66.41 ms
Size 1.58 MiB 2.29 MiB 723.29 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
e59e22a 329.74 ms 383.31 ms 53.57 ms
fc5ccaf 270.49 ms 363.90 ms 93.41 ms
d15471f 361.89 ms 378.07 ms 16.18 ms
d15471f 322.58 ms 396.08 ms 73.50 ms
abfcc92 304.04 ms 370.33 ms 66.29 ms
91bb874 310.68 ms 359.24 ms 48.56 ms
ab8a72d 316.24 ms 356.38 ms 40.14 ms
d15471f 286.65 ms 314.68 ms 28.03 ms
6727e14 337.22 ms 373.94 ms 36.71 ms
f064536 329.00 ms 395.62 ms 66.62 ms

App size

Revision Plain With Sentry Diff
e59e22a 1.58 MiB 2.20 MiB 635.34 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
abfcc92 1.58 MiB 2.13 MiB 557.31 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
ab8a72d 1.58 MiB 2.12 MiB 551.55 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
6727e14 1.58 MiB 2.28 MiB 718.64 KiB
f064536 1.58 MiB 2.20 MiB 633.90 KiB

@adinauer
Copy link
Member Author

adinauer commented Mar 3, 2026

PR Stack (Cache Tracing)

  • #5137 — Add SentryCacheWrapper and SentryCacheManagerWrapper
  • #5141 — Add enableCacheTracing option
  • #5142 — Add BeanPostProcessor and auto-configuration

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