Skip to content

Commit 0a6da6f

Browse files
adinauerclaude
andcommitted
feat(samples): Add Caffeine cache to Spring Boot sample
Enable cache tracing in the Spring Boot 2/3 sample using Caffeine as an in-memory cache provider. No external infrastructure required. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 89b88b0 commit 0a6da6f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ dependencies {
5050
implementation(projects.sentryQuartz)
5151
implementation(projects.sentryAsyncProfiler)
5252

53+
// cache tracing
54+
implementation("com.github.ben-manes.caffeine:caffeine")
55+
5356
// database query tracing
5457
implementation(projects.sentryJdbc)
5558
runtimeOnly(libs.hsqldb)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.springframework.boot.SpringApplication;
1010
import org.springframework.boot.autoconfigure.SpringBootApplication;
1111
import org.springframework.boot.web.client.RestTemplateBuilder;
12+
import org.springframework.cache.annotation.EnableCaching;
1213
import org.springframework.context.annotation.Bean;
1314
import org.springframework.scheduling.annotation.EnableScheduling;
1415
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
@@ -18,6 +19,7 @@
1819
import org.springframework.web.reactive.function.client.WebClient;
1920

2021
@SpringBootApplication
22+
@EnableCaching
2123
@EnableScheduling
2224
public class SentryDemoApplication {
2325
public static void main(String[] args) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ sentry.profile-session-sample-rate=1.0
2020
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
2121
sentry.profile-lifecycle=TRACE
2222

23+
# Cache tracing
24+
sentry.enable-cache-tracing=true
25+
spring.cache.cache-names=todos
26+
spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s
27+
2328
# Database configuration
2429
spring.datasource.url=jdbc:p6spy:hsqldb:mem:testdb
2530
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver

0 commit comments

Comments
 (0)