Skip to content

test(spring-boot-jakarta): [Queue Instrumentation 22] Cover spring-kafka class-absence gate#5318

Draft
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-preserve-baggagefrom
test/queue-instrumentation-kafka-autoconfig-class-gate
Draft

test(spring-boot-jakarta): [Queue Instrumentation 22] Cover spring-kafka class-absence gate#5318
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-preserve-baggagefrom
test/queue-instrumentation-kafka-autoconfig-class-gate

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 21, 2026

PR Stack (Queue Instrumentation)


📜 Description

SentryKafkaQueueConfiguration in SentryAutoConfiguration is gated on two classes being present on the classpath:

@ConditionalOnClass(name = {
  "org.springframework.kafka.core.KafkaTemplate",
  "io.sentry.kafka.SentryKafkaProducerInterceptor"
})

Only the SentryKafkaProducerInterceptor-missing half of that gate had test coverage. This PR adds a FilteredClassLoader(KafkaTemplate::class.java) test that asserts neither SentryKafkaProducerBeanPostProcessor nor SentryKafkaConsumerBeanPostProcessor is registered when spring-kafka is missing, even with sentry.enable-queue-tracing=true.

💡 Motivation and Context

Round out the class-absence gate coverage in SentryKafkaAutoConfigurationTest so the autoconfig contract for spring-kafka being absent is explicitly pinned by a test.

💚 How did you test it?

  • ./gradlew :sentry-spring-boot-jakarta:test --tests='io.sentry.spring.boot.jakarta.SentryKafkaAutoConfigurationTest' — 6/6 pass (incl. new does not register Kafka BPPs when spring-kafka is not present).
  • ./gradlew spotlessApply apiDump — clean.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

None.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

…fka class-absence gate

`SentryKafkaQueueConfiguration` in `SentryAutoConfiguration` gates the
Kafka BPPs on both `org.springframework.kafka.core.KafkaTemplate` and
`io.sentry.kafka.SentryKafkaProducerInterceptor` being present on the
classpath. Only the latter was covered by a test.

Add a `FilteredClassLoader(KafkaTemplate::class.java)` test that asserts
neither `SentryKafkaProducerBeanPostProcessor` nor
`SentryKafkaConsumerBeanPostProcessor` is registered when spring-kafka
is missing, even with `sentry.enable-queue-tracing=true`.

Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Apr 21, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 21, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.37.1 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 332.53 ms 401.24 ms 68.71 ms
Size 0 B 0 B 0 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant