fix(spring): [Cache Tracing 24] Track invalidate cache.write accurately#5231
Merged
adinauer merged 1 commit intofeat/cache-tracingfrom Mar 25, 2026
Merged
Conversation
Set cache.write based on delegate.invalidate() result instead of always true. This keeps span data aligned with Spring's invalidate semantics when no entries were present. Add tests in spring, spring-jakarta, and spring-7 wrappers to cover the false return path and assert cache.write is false. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Sentry Build Distribution
|
Member
Author
|
@sentry review |
Member
Author
|
cursor review |
Contributor
alexander-alderman-webb
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Cache Tracing)
📜 Description
This fixes cache span data correctness for
invalidate()across Spring cache wrappers (sentry-spring,sentry-spring-jakarta, andsentry-spring-7).Previously,
cache.writewas always set totrueafterdelegate.invalidate(), even wheninvalidate()returnedfalse(no mappings were present or presence could not be determined). This PR setscache.writeto the actual returned boolean.It also adds regression tests in all three wrapper test suites to verify the
falsepath.💡 Motivation and Context
During PR review, we found that span data could over-report writes for cache flush operations. This makes span attributes less trustworthy for downstream analysis.
This change aligns span data with Spring's documented
Cache.invalidate()semantics.💚 How did you test it?
./gradlew :sentry-spring:test --tests="*SentryCacheWrapperTest*" :sentry-spring-jakarta:test --tests="*SentryCacheWrapperTest*" :sentry-spring-7:test --tests="*SentryCacheWrapperTest*"invalidate sets cache write false when cache had no mappings📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
feat/cache-tracingtomain.#skip-changelog