feat(jcache): [Cache Tracing 5] Add SentryJCacheWrapper for JCache (JSR-107)#5179
feat(jcache): [Cache Tracing 5] Add SentryJCacheWrapper for JCache (JSR-107)#5179adinauer wants to merge 10 commits intofeat/cache-tracing-samplefrom
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Core
Spring
Other
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
|
Sentry Build Distribution
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0ceb700 | 305.81 ms | 355.91 ms | 50.10 ms |
| 855766f | 364.82 ms | 427.16 ms | 62.35 ms |
| eeb463c | 311.36 ms | 371.79 ms | 60.43 ms |
| b2b863f | 338.62 ms | 376.54 ms | 37.92 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0ceb700 | 0 B | 0 B | 0 B |
| 855766f | 0 B | 0 B | 0 B |
| eeb463c | 0 B | 0 B | 0 B |
| b2b863f | 0 B | 0 B | 0 B |
Previous results on branch: feat/cache-tracing-jcache
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bff862e | 315.13 ms | 364.41 ms | 49.28 ms |
| 10c6fa4 | 308.73 ms | 384.38 ms | 75.66 ms |
| 290c35b | 320.64 ms | 355.09 ms | 34.45 ms |
| c3caf85 | 313.96 ms | 352.98 ms | 39.02 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bff862e | 0 B | 0 B | 0 B |
| 10c6fa4 | 0 B | 0 B | 0 B |
| 290c35b | 0 B | 0 B | 0 B |
| c3caf85 | 0 B | 0 B | 0 B |
Like putIfAbsent, these are conditional writes that may be no-ops. Emitting a cache.put span for them would be misleading.
Sentry Build Distribution
|
startChild can return a NoOp span (e.g. when span limit is reached). Skip instrumentation in that case to avoid unnecessary work.
Sentry Build Distribution
|
removeAll() with no args removes all entries, which is semantically equivalent to clear(). Use cache.flush instead of cache.remove. The keyed removeAll(Set) remains cache.remove.
Sentry Build Distribution
|
Sentry Build Distribution
|
Sentry Build Distribution
|
Sentry Build Distribution
|
|
cursor review |
|
@sentry review |
1 similar comment
|
@sentry review |
|
cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } finally { | ||
| span.finish(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Conditional remove(K,V) instrumented unlike other conditional ops
Low Severity
remove(K, V) is a conditional operation (only removes if the current value matches) but is instrumented with a cache.remove span. Meanwhile, replace(K, V), replace(K, V, V), and getAndReplace are also conditional operations but are explicitly made passthrough with the comment that "conditional writes…emitting a cache.put span for a potential no-op would be misleading." The same reasoning applies equally to remove(K, V) — it can be a no-op when the value doesn't match — yet it still emits a cache.remove span with SpanStatus.OK.
Additional Locations (1)
Sentry Build Distribution
|


PR Stack (Cache Tracing)
📜 Description
Adds a new
sentry-jcachemodule that provides cache tracing for apps using the JCache (JSR-107) API.SentryJCacheWrapper<K,V>implementsjavax.cache.Cache<K,V>and creates Sentry spans for cache operations:cache.get—get,getAll,invoke,invokeAllcache.put—put,getAndPut,putAll,replace,getAndReplacecache.remove—remove,getAndRemove,removeAllcache.flush—clearputIfAbsent,containsKey,close,loadAll, metadata methods, listener registration,iteratorSets
cache.hit,cache.keyspan attributes viaSpanDataConvention. Gated onisEnableCacheTracing(). Trace origin:auto.cache.jcache.💡 Motivation and Context
Spring Cache covers Spring users, but many Java apps use JCache directly (plain Java, Micronaut, CDI/Jakarta EE). This module provides the same cache tracing experience for those users. JCache never migrated to Jakarta namespace, so
javax.cacheworks everywhere.💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
sentry-spring-jakartaandsentry-spring