From bbed2d2379dec023232c657ef3bd836c1663f729 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 23 Apr 2026 14:28:44 +0200 Subject: [PATCH] test(spring-boot-jakarta): [Queue Instrumentation 32] Filter OTel in Kafka auto-config negative tests The regression tests "does not register Kafka BPPs when sentry-kafka is not present" and "...when spring-kafka is not present" previously passed for the wrong reason: OTel's SentryAutoConfigurationCustomizerProvider is on the test classpath as a testImplementation dependency, so the @ConditionalOnMissingClass(OTel) gate on SentryKafkaQueueConfiguration was already blocking the beans independent of the @ConditionalOnClass check the tests were meant to validate. Make noSentryKafkaClassLoader and noSpringKafkaClassLoader additionally filter SentryAutoConfigurationCustomizerProvider so only the gate under test can be the blocker. Verified by temporarily removing SentryKafkaProducerInterceptor from the @ConditionalOnClass list: the test now correctly fails, proving it actually guards against the regression it is named for. Co-Authored-By: Claude --- .../boot/jakarta/SentryKafkaAutoConfigurationTest.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryKafkaAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryKafkaAutoConfigurationTest.kt index 2f035936b5..c3a4c12e35 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryKafkaAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryKafkaAutoConfigurationTest.kt @@ -33,9 +33,16 @@ class SentryKafkaAutoConfigurationTest { FilteredClassLoader(SentryAutoConfigurationCustomizerProvider::class.java) private val noSentryKafkaClassLoader = - FilteredClassLoader(SentryKafkaProducerInterceptor::class.java) + FilteredClassLoader( + SentryKafkaProducerInterceptor::class.java, + SentryAutoConfigurationCustomizerProvider::class.java, + ) - private val noSpringKafkaClassLoader = FilteredClassLoader(KafkaTemplate::class.java) + private val noSpringKafkaClassLoader = + FilteredClassLoader( + KafkaTemplate::class.java, + SentryAutoConfigurationCustomizerProvider::class.java, + ) @Test fun `registers Kafka BPPs when queue tracing is enabled`() {