Skip to content

Commit dbb2998

Browse files
adinauerclaude
andcommitted
feat(jcache): Add SentryJCacheWrapper ctor that uses ScopesAdapter
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d797a2d commit dbb2998

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

sentry-jcache/api/sentry-jcache.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public final class io/sentry/jcache/BuildConfig {
44
}
55

66
public final class io/sentry/jcache/SentryJCacheWrapper : javax/cache/Cache {
7+
public fun <init> (Ljavax/cache/Cache;)V
78
public fun <init> (Ljavax/cache/Cache;Lio/sentry/IScopes;)V
89
public fun clear ()V
910
public fun close ()V

sentry-jcache/src/main/java/io/sentry/jcache/SentryJCacheWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.sentry.IScopes;
44
import io.sentry.ISpan;
5+
import io.sentry.ScopesAdapter;
56
import io.sentry.SpanDataConvention;
67
import io.sentry.SpanOptions;
78
import io.sentry.SpanStatus;
@@ -36,6 +37,10 @@ public final class SentryJCacheWrapper<K, V> implements Cache<K, V> {
3637
private final @NotNull Cache<K, V> delegate;
3738
private final @NotNull IScopes scopes;
3839

40+
public SentryJCacheWrapper(final @NotNull Cache<K, V> delegate) {
41+
this(delegate, ScopesAdapter.getInstance());
42+
}
43+
3944
public SentryJCacheWrapper(final @NotNull Cache<K, V> delegate, final @NotNull IScopes scopes) {
4045
this.delegate = delegate;
4146
this.scopes = scopes;

sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private static void demonstrateCacheTracing() {
211211
Cache<String, String> rawCache = cacheManager.createCache("myCache", config);
212212

213213
// Wrap with SentryJCacheWrapper to enable cache tracing
214-
Cache<String, String> cache = new SentryJCacheWrapper<>(rawCache, Sentry.getCurrentScopes());
214+
Cache<String, String> cache = new SentryJCacheWrapper<>(rawCache);
215215

216216
// All cache operations inside a transaction produce child spans
217217
ITransaction transaction = Sentry.startTransaction("cache-demo", "demo");

0 commit comments

Comments
 (0)