Skip to content

Commit cf3b325

Browse files
adinauerclaude
andcommitted
ref(samples): Replace ConcurrentMapCacheManager with Caffeine
Use Caffeine as the cache provider instead of a plain ConcurrentMapCacheManager. Spring Boot auto-configures CaffeineCacheManager when Caffeine is on the classpath, so the explicit CacheManager bean is no longer needed. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ae0f569 commit cf3b325

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

sentry-samples/sentry-samples-spring-boot-4/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ dependencies {
5757
implementation(projects.sentryQuartz)
5858
implementation(projects.sentryAsyncProfiler)
5959

60+
// cache tracing
61+
implementation("com.github.ben-manes.caffeine:caffeine")
62+
6063
// database query tracing
6164
implementation(projects.sentryJdbc)
6265
runtimeOnly(libs.hsqldb)

sentry-samples/sentry-samples-spring-boot-4/src/main/java/io/sentry/samples/spring/boot4/SentryDemoApplication.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import org.springframework.boot.SpringApplication;
1010
import org.springframework.boot.autoconfigure.SpringBootApplication;
1111
import org.springframework.boot.restclient.RestTemplateBuilder;
12-
import org.springframework.cache.CacheManager;
1312
import org.springframework.cache.annotation.EnableCaching;
14-
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
1513
import org.springframework.context.annotation.Bean;
1614
import org.springframework.scheduling.annotation.EnableScheduling;
1715
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
@@ -29,11 +27,6 @@ public static void main(String[] args) {
2927
SpringApplication.run(SentryDemoApplication.class, args);
3028
}
3129

32-
@Bean
33-
CacheManager cacheManager() {
34-
return new ConcurrentMapCacheManager("todos");
35-
}
36-
3730
@Bean
3831
RestTemplate restTemplate(RestTemplateBuilder builder) {
3932
return builder.build();

sentry-samples/sentry-samples-spring-boot-4/src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ sentry.profile-session-sample-rate=1.0
2121
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
2222
sentry.profile-lifecycle=TRACE
2323
sentry.enable-cache-tracing=true
24+
spring.cache.cache-names=todos
25+
spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s
2426

2527
# Uncomment and set to true to enable aot compatibility
2628
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)

0 commit comments

Comments
 (0)