Skip to content

Commit 87b8bc3

Browse files
adinauerclaude
andcommitted
fix(spring): Exclude Kafka from old Boot 2 matrix
Spring Kafka sample support depends on newer Spring Boot 2 dependency management. Exclude Kafka sources, profile startup, and system tests when the matrix runs Boot 2 versions before 2.7. Keep the system test classpath aligned with the SDK test helpers by importing the OkHttp and Jackson BOMs after the tested Spring Boot BOMs. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b8a9c0b commit 87b8bc3

7 files changed

Lines changed: 53 additions & 17 deletions

File tree

.github/workflows/spring-boot-2-matrix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
fi
6969
if [[ ! "$springboot_version" =~ ^2\.7\. ]]; then
7070
echo "ORG_GRADLE_PROJECT_excludeGraphql=true" >> "$GITHUB_ENV"
71+
echo "ORG_GRADLE_PROJECT_excludeKafka=true" >> "$GITHUB_ENV"
7172
fi
7273
sed -i 's/^\(springboot2[[:space:]]*=[[:space:]]*\)".*"/\1"'"$springboot_version"'"/' gradle/libs.versions.toml
7374
echo "Updated Spring Boot 2.x version to $springboot_version"

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ java.targetCompatibility = JavaVersion.VERSION_11
2121

2222
repositories { mavenCentral() }
2323

24-
fun springBoot2SupportsGraphql(): Boolean {
24+
fun springBoot2SupportsOptionalIntegrations(): Boolean {
2525
val version = libs.versions.springboot2.get().removeSuffix(".RELEASE")
2626
val parts = version.split(".").map { it.toIntOrNull() ?: 0 }
2727
val major = parts.getOrElse(0) { 0 }
2828
val minor = parts.getOrElse(1) { 0 }
2929
return major > 2 || (major == 2 && minor >= 7)
3030
}
3131

32-
val includeGraphql = !project.hasProperty("excludeGraphql") && springBoot2SupportsGraphql()
32+
val includeGraphql =
33+
!project.hasProperty("excludeGraphql") && springBoot2SupportsOptionalIntegrations()
34+
val includeKafka = !project.hasProperty("excludeKafka") && springBoot2SupportsOptionalIntegrations()
3335

3436
configure<JavaPluginExtension> {
3537
sourceCompatibility = JavaVersion.VERSION_11
@@ -74,9 +76,10 @@ dependencies {
7476
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring)
7577
implementation(projects.sentryAsyncProfiler)
7678

77-
// kafka
78-
implementation(libs.spring.kafka2)
79-
implementation(projects.sentryKafka)
79+
if (includeKafka) {
80+
implementation(libs.spring.kafka2)
81+
implementation(projects.sentryKafka)
82+
}
8083

8184
// database query tracing
8285
implementation(projects.sentryJdbc)
@@ -123,6 +126,10 @@ configure<SourceSetContainer> {
123126
java.exclude("**/graphql/**")
124127
resources.exclude("graphql/**")
125128
}
129+
if (!includeKafka) {
130+
java.exclude("**/queues/kafka/**")
131+
resources.exclude("application-kafka.properties")
132+
}
126133
}
127134
test { java.srcDir("src/test/java") }
128135
}
@@ -148,6 +155,9 @@ tasks.register<Test>("systemTest").configure {
148155
if (!includeGraphql) {
149156
excludeTestsMatching("io.sentry.systemtest.Graphql*")
150157
}
158+
if (!includeKafka) {
159+
excludeTestsMatching("io.sentry.systemtest.Kafka*")
160+
}
151161
}
152162
}
153163

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ java.targetCompatibility = JavaVersion.VERSION_11
2121

2222
repositories { mavenCentral() }
2323

24-
fun springBoot2SupportsGraphql(): Boolean {
24+
fun springBoot2SupportsOptionalIntegrations(): Boolean {
2525
val version = libs.versions.springboot2.get().removeSuffix(".RELEASE")
2626
val parts = version.split(".").map { it.toIntOrNull() ?: 0 }
2727
val major = parts.getOrElse(0) { 0 }
2828
val minor = parts.getOrElse(1) { 0 }
2929
return major > 2 || (major == 2 && minor >= 7)
3030
}
3131

32-
val includeGraphql = !project.hasProperty("excludeGraphql") && springBoot2SupportsGraphql()
32+
val includeGraphql =
33+
!project.hasProperty("excludeGraphql") && springBoot2SupportsOptionalIntegrations()
34+
val includeKafka = !project.hasProperty("excludeKafka") && springBoot2SupportsOptionalIntegrations()
3335

3436
configure<JavaPluginExtension> {
3537
sourceCompatibility = JavaVersion.VERSION_11
@@ -70,9 +72,10 @@ dependencies {
7072
implementation(projects.sentryAsyncProfiler)
7173
implementation(libs.otel)
7274

73-
// kafka
74-
implementation(libs.spring.kafka2)
75-
implementation(projects.sentryKafka)
75+
if (includeKafka) {
76+
implementation(libs.spring.kafka2)
77+
implementation(projects.sentryKafka)
78+
}
7679

7780
// database query tracing
7881
implementation(projects.sentryJdbc)
@@ -119,6 +122,10 @@ configure<SourceSetContainer> {
119122
java.exclude("**/graphql/**")
120123
resources.exclude("graphql/**")
121124
}
125+
if (!includeKafka) {
126+
java.exclude("**/queues/kafka/**")
127+
resources.exclude("application-kafka.properties")
128+
}
122129
}
123130
test { java.srcDir("src/test/java") }
124131
}
@@ -168,6 +175,9 @@ tasks.register<Test>("systemTest").configure {
168175
if (!includeGraphql) {
169176
excludeTestsMatching("io.sentry.systemtest.Graphql*")
170177
}
178+
if (!includeKafka) {
179+
excludeTestsMatching("io.sentry.systemtest.Kafka*")
180+
}
171181
}
172182
}
173183

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ java.targetCompatibility = JavaVersion.VERSION_11
2121

2222
repositories { mavenCentral() }
2323

24-
fun springBoot2SupportsGraphql(): Boolean {
24+
fun springBoot2SupportsOptionalIntegrations(): Boolean {
2525
val version = libs.versions.springboot2.get().removeSuffix(".RELEASE")
2626
val parts = version.split(".").map { it.toIntOrNull() ?: 0 }
2727
val major = parts.getOrElse(0) { 0 }
2828
val minor = parts.getOrElse(1) { 0 }
2929
return major > 2 || (major == 2 && minor >= 7)
3030
}
3131

32-
val includeGraphql = !project.hasProperty("excludeGraphql") && springBoot2SupportsGraphql()
32+
val includeGraphql =
33+
!project.hasProperty("excludeGraphql") && springBoot2SupportsOptionalIntegrations()
34+
val includeKafka = !project.hasProperty("excludeKafka") && springBoot2SupportsOptionalIntegrations()
3335

3436
configure<JavaPluginExtension> {
3537
sourceCompatibility = JavaVersion.VERSION_11
@@ -60,9 +62,10 @@ dependencies {
6062
implementation(libs.springboot.starter.websocket)
6163
implementation(libs.caffeine)
6264

63-
// kafka
64-
implementation(libs.spring.kafka2)
65-
implementation(projects.sentryKafka)
65+
if (includeKafka) {
66+
implementation(libs.spring.kafka2)
67+
implementation(projects.sentryKafka)
68+
}
6669
implementation(Config.Libs.aspectj)
6770
implementation(Config.Libs.kotlinReflect)
6871
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
@@ -122,6 +125,10 @@ configure<SourceSetContainer> {
122125
java.exclude("**/graphql/**")
123126
resources.exclude("graphql/**")
124127
}
128+
if (!includeKafka) {
129+
java.exclude("**/queues/kafka/**")
130+
resources.exclude("application-kafka.properties")
131+
}
125132
}
126133
test { java.srcDir("src/test/java") }
127134
}
@@ -147,6 +154,9 @@ tasks.register<Test>("systemTest").configure {
147154
if (!includeGraphql) {
148155
excludeTestsMatching("io.sentry.systemtest.Graphql*")
149156
}
157+
if (!includeKafka) {
158+
excludeTestsMatching("io.sentry.systemtest.Kafka*")
159+
}
150160
}
151161
}
152162

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencyManagement {
3131
imports {
3232
mavenBom("org.springframework.boot:spring-boot-dependencies:${libs.versions.springboot3.get()}")
3333
mavenBom(libs.kotlin.bom.get().toString())
34+
mavenBom(libs.jackson.bom.get().toString())
3435
}
3536
}
3637

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencyManagement {
3333
mavenBom(libs.springboot2.bom.get().toString())
3434
mavenBom(libs.kotlin.bom.get().toString())
3535
mavenBom(libs.jackson.bom.get().toString())
36+
mavenBom(libs.okhttp.bom.get().toString())
3637
}
3738
}
3839

test/system-test-runner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,14 @@ def kill_process(self, pid: int, name: str) -> None:
224224
except (OSError, ProcessLookupError):
225225
print(f"Process {pid} was already dead")
226226

227+
def exclude_kafka(self) -> bool:
228+
return os.environ.get("ORG_GRADLE_PROJECT_excludeKafka") == "true"
229+
227230
def module_requires_kafka(self, sample_module: str) -> bool:
228-
return sample_module in KAFKA_BROKER_REQUIRED_MODULES
231+
return not self.exclude_kafka() and sample_module in KAFKA_BROKER_REQUIRED_MODULES
229232

230233
def module_requires_kafka_profile(self, sample_module: str) -> bool:
231-
return sample_module in KAFKA_PROFILE_REQUIRED_MODULES
234+
return not self.exclude_kafka() and sample_module in KAFKA_PROFILE_REQUIRED_MODULES
232235

233236
def wait_for_port(self, host: str, port: int, max_attempts: int = 20) -> bool:
234237
for _ in range(max_attempts):

0 commit comments

Comments
 (0)