fix(spring-boot-jakarta): [Queue Instrumentation 8] Disable Sentry Kafka spans when OTel is active#5274
Draft
adinauer wants to merge 2 commits intofeat/queue-instrumentation-otel-samplesfrom
Conversation
…Tel is active Skip registration of SentryKafkaProducerBeanPostProcessor and SentryKafkaConsumerBeanPostProcessor when a Sentry OpenTelemetry integration (agent or agentless) is on the classpath. OpenTelemetry provides its own Kafka instrumentation, so Sentry's would create duplicate spans.
Add auto.queue.spring_jakarta.kafka.producer and auto.queue.spring_jakarta.kafka.consumer to the ignored span origins when running with OTel agent or agentless-spring. Prevents duplicate spans when both Sentry and OTel Kafka instrumentation are active.
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
This was referenced Apr 7, 2026
Sentry Build Distribution
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b1d1e92 | 316.78 ms | 368.92 ms | 52.14 ms |
| 177822e | 299.07 ms | 325.31 ms | 26.24 ms |
| a2180d6 | 359.90 ms | 423.92 ms | 64.02 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b1d1e92 | 0 B | 0 B | 0 B |
| 177822e | 0 B | 0 B | 0 B |
| a2180d6 | 0 B | 0 B | 0 B |
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
Disable Sentry's Kafka queue instrumentation when a Sentry OpenTelemetry integration (agent or agentless) is active, to avoid duplicate spans:
@ConditionalOnMissingClass("io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider")toSentryKafkaQueueConfigurationso the Kafka bean post processors are not registered when OTel is present.auto.queue.spring_jakarta.kafka.producerandauto.queue.spring_jakarta.kafka.consumertoSpanUtils.ignoredSpanOriginsForOpenTelemetry()for AGENT and AGENTLESS_SPRING modes as a second layer of protection.💡 Motivation and Context
OpenTelemetry provides its own Kafka instrumentation. When both Sentry and OTel instrument Kafka, duplicate spans are created. This disables the Sentry side when OTel handles it.
💚 How did you test it?
Unit tests in
SentryKafkaAutoConfigurationTest— added a test verifying beans are not registered when OTel is present, and updated existing tests to useFilteredClassLoaderto simulate OTel absence.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#skip-changelog