Skip to content
Open
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Add cache tracing instrumentation for Spring Boot 4 ([#5172](https://github.com/getsentry/sentry-java/pull/5172), [#5173](https://github.com/getsentry/sentry-java/pull/5173), [#5174](https://github.com/getsentry/sentry-java/pull/5174))
- Wraps Spring `CacheManager` and `Cache` beans to produce `cache.get`, `cache.put`, `cache.remove`, and `cache.flush` spans
- Set `sentry.enable-cache-tracing` to `true` to enable this feature
- Add JCache (JSR-107) cache tracing via new `sentry-jcache` module ([#5179](https://github.com/getsentry/sentry-java/pull/5179))
- Wraps JCache `Cache` with `SentryJCacheWrapper` to produce `cache.get`, `cache.put`, `cache.remove`, and `cache.flush` spans
- Set `sentry.enable-cache-tracing` to `true` to enable this feature

## 8.34.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Sentry SDK for Java and Android
| sentry-graphql | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-graphql?style=for-the-badge&logo=sentry&color=green) |
| sentry-graphql-core | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-graphql-core?style=for-the-badge&logo=sentry&color=green) |
| sentry-graphql-22 | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-graphql-22?style=for-the-badge&logo=sentry&color=green) |
| sentry-jcache | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-jcache?style=for-the-badge&logo=sentry&color=green) |
| sentry-quartz | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-quartz?style=for-the-badge&logo=sentry&color=green) |
| sentry-openfeign | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-openfeign?style=for-the-badge&logo=sentry&color=green) |
| sentry-openfeature | ![Maven Central Version](https://img.shields.io/maven-central/v/io.sentry/sentry-openfeature?style=for-the-badge&logo=sentry&color=green) |
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ object Config {
val SENTRY_GRAPHQL_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql"
val SENTRY_GRAPHQL_CORE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql-core"
val SENTRY_GRAPHQL22_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.graphql22"
val SENTRY_JCACHE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.jcache"
val SENTRY_QUARTZ_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.quartz"
val SENTRY_JDBC_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.jdbc"
val SENTRY_OPENFEATURE_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.openfeature"
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ otel-semconv = { module = "io.opentelemetry.semconv:opentelemetry-semconv", vers
otel-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "otelSemanticConventionsAlpha" }
p6spy = { module = "p6spy:p6spy", version = "3.9.1" }
epitaph = { module = "com.abovevacant:epitaph", version = "0.1.0" }
jcache = { module = "javax.cache:cache-api", version = "1.1.1" }
quartz = { module = "org.quartz-scheduler:quartz", version = "2.3.0" }
reactor-core = { module = "io.projectreactor:reactor-core", version = "3.5.3" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
Expand Down
13 changes: 13 additions & 0 deletions sentry-jcache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# sentry-jcache

This module provides an integration for JCache (JSR-107).

JCache is a standard API — you need a provider implementation at runtime. Common implementations include:

- [Caffeine](https://github.com/ben-manes/caffeine) (via `com.github.ben-manes.caffeine:jcache`)
- [Ehcache 3](https://www.ehcache.org/) (via `org.ehcache:ehcache`)
- [Hazelcast](https://hazelcast.com/)
- [Apache Ignite](https://ignite.apache.org/)
- [Infinispan](https://infinispan.org/)

Please consult the documentation on how to install and use this integration in the Sentry Docs for [Java](https://docs.sentry.io/platforms/java/tracing/instrumentation/jcache/).
37 changes: 37 additions & 0 deletions sentry-jcache/api/sentry-jcache.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public final class io/sentry/jcache/BuildConfig {
public static final field SENTRY_JCACHE_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

public final class io/sentry/jcache/SentryJCacheWrapper : javax/cache/Cache {
public fun <init> (Ljavax/cache/Cache;Lio/sentry/IScopes;)V
public fun clear ()V
public fun close ()V
public fun containsKey (Ljava/lang/Object;)Z
public fun deregisterCacheEntryListener (Ljavax/cache/configuration/CacheEntryListenerConfiguration;)V
public fun get (Ljava/lang/Object;)Ljava/lang/Object;
public fun getAll (Ljava/util/Set;)Ljava/util/Map;
public fun getAndPut (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public fun getAndRemove (Ljava/lang/Object;)Ljava/lang/Object;
public fun getAndReplace (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public fun getCacheManager ()Ljavax/cache/CacheManager;
public fun getConfiguration (Ljava/lang/Class;)Ljavax/cache/configuration/Configuration;
public fun getName ()Ljava/lang/String;
public fun invoke (Ljava/lang/Object;Ljavax/cache/processor/EntryProcessor;[Ljava/lang/Object;)Ljava/lang/Object;
public fun invokeAll (Ljava/util/Set;Ljavax/cache/processor/EntryProcessor;[Ljava/lang/Object;)Ljava/util/Map;
public fun isClosed ()Z
public fun iterator ()Ljava/util/Iterator;
public fun loadAll (Ljava/util/Set;ZLjavax/cache/integration/CompletionListener;)V
public fun put (Ljava/lang/Object;Ljava/lang/Object;)V
public fun putAll (Ljava/util/Map;)V
public fun putIfAbsent (Ljava/lang/Object;Ljava/lang/Object;)Z
public fun registerCacheEntryListener (Ljavax/cache/configuration/CacheEntryListenerConfiguration;)V
public fun remove (Ljava/lang/Object;)Z
public fun remove (Ljava/lang/Object;Ljava/lang/Object;)Z
public fun removeAll ()V
public fun removeAll (Ljava/util/Set;)V
public fun replace (Ljava/lang/Object;Ljava/lang/Object;)Z
public fun replace (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z
public fun unwrap (Ljava/lang/Class;)Ljava/lang/Object;
}

90 changes: 90 additions & 0 deletions sentry-jcache/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`java-library`
id("io.sentry.javadoc")
alias(libs.plugins.kotlin.jvm)
jacoco
alias(libs.plugins.errorprone)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.buildconfig)
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
}

dependencies {
api(projects.sentry)
compileOnly(libs.jcache)

compileOnly(libs.jetbrains.annotations)
compileOnly(libs.nopen.annotations)
errorprone(libs.errorprone.core)
errorprone(libs.nopen.checker)
errorprone(libs.nullaway)

// tests
testImplementation(projects.sentry)
testImplementation(projects.sentryTestSupport)
testImplementation(libs.jcache)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.mockito.inline)
}

configure<SourceSetContainer> { test { java.srcDir("src/test/java") } }

jacoco { toolVersion = libs.versions.jacoco.get() }

tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(false)
}
}

tasks {
jacocoTestCoverageVerification {
violationRules { rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } } }
}
check {
dependsOn(jacocoTestCoverageVerification)
dependsOn(jacocoTestReport)
}
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "io.sentry")
}
}

buildConfig {
useJavaOutput()
packageName("io.sentry.jcache")
buildConfigField(
"String",
"SENTRY_JCACHE_SDK_NAME",
"\"${Config.Sentry.SENTRY_JCACHE_SDK_NAME}\"",
)
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

tasks.jar {
manifest {
attributes(
"Sentry-Version-Name" to project.version,
"Sentry-SDK-Name" to Config.Sentry.SENTRY_JCACHE_SDK_NAME,
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-jcache",
"Implementation-Vendor" to "Sentry",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
)
}
}
Loading
Loading