test(spring-boot-jakarta): [Queue Instrumentation 32] Filter OTel in Kafka auto-config negative tests#5330
Open
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-enqueued-time-formatfrom
Conversation
…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 <noreply@anthropic.com>
This was referenced Apr 23, 2026
Open
Open
This was referenced Apr 23, 2026
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Queue Instrumentation)
📜 Description
Fix the Kafka auto-config negative regression tests so they validate the
@ConditionalOnClassgate they claim to guard.SentryKafkaQueueConfigurationis gated by three annotations:@ConditionalOnClass({KafkaTemplate, SentryKafkaProducerInterceptor})@ConditionalOnProperty("sentry.enable-queue-tracing" = "true")@ConditionalOnMissingClass("io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider")The regression tests
does not register Kafka BPPs when sentry-kafka is not presentand...when spring-kafka is not presentusedFilteredClassLoaderto hideSentryKafkaProducerInterceptor/KafkaTemplaterespectively, asserting the BPPs are absent. Butsentry-opentelemetry-agentless-springis ontestImplementation, soSentryAutoConfigurationCustomizerProvideris always on the test classpath — gate #3 was already blocking the config independent of gate #1. The tests passed for the wrong reason: if someone removed a class from@ConditionalOnClass, they would still pass.Extend both
FilteredClassLoaders to additionally filterSentryAutoConfigurationCustomizerProvider, so gate #3 is satisfied and only the gate under test can be the blocker. With this change, temporarily removing"io.sentry.kafka.SentryKafkaProducerInterceptor"from@ConditionalOnClasscauses thesentry-kafka not presenttest to correctly fail — confirmed locally before restoring the gate.Addresses review8.md finding R8-F005.
💡 Motivation and Context
PR #5291 introduced these negative regression tests to guard against the
NoClassDefFoundErrorscenario from review finding R8-F003 (sentry-kafkaabsent butspring-kafkapresent with queue tracing enabled →@ConditionalOnClassmust skip the configuration). The tests passed, so the gate was presumed covered. The audit in review8 showed the tests could not detect a regression because an unrelated gate was doing the work. Fixing this ensures the regression test is load-bearing, not decorative.💚 How did you test it?
./gradlew :sentry-spring-boot-jakarta:test --tests SentryKafkaAutoConfigurationTest— all 6 tests pass."io.sentry.kafka.SentryKafkaProducerInterceptor"from@ConditionalOnClass→does not register Kafka BPPs when sentry-kafka is not presentnow fails (as it should). Gate restored../gradlew spotlessApply apiDump— clean.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Remaining open items on the Queue Instrumentation stack after this PR:
test/system-test-runner.pystop_kafka_broker()guard prevents pre-start stale-container cleanup from running.SentryKafkaProducerBeanPostProcessordoes not detect aSentryKafkaProducerInterceptornested inside aCompositeProducerInterceptor(double-wrapping risk).#skip-changelog