Skip to content

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
fix/queue-instrumentation-otel-dedup
Draft

fix(spring-boot-jakarta): [Queue Instrumentation 8] Disable Sentry Kafka spans when OTel is active#5274
adinauer wants to merge 2 commits intofeat/queue-instrumentation-otel-samplesfrom
fix/queue-instrumentation-otel-dedup

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 7, 2026

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:

  1. Auto-configuration guard: Add @ConditionalOnMissingClass("io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider") to SentryKafkaQueueConfiguration so the Kafka bean post processors are not registered when OTel is present.
  2. Ignored span origins: Add auto.queue.spring_jakarta.kafka.producer and auto.queue.spring_jakarta.kafka.consumer to SpanUtils.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 use FilteredClassLoader to simulate OTel absence.

📝 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

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

#skip-changelog

adinauer added 2 commits April 7, 2026 12:35
…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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 7, 2026

Sentry Build Distribution

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 367.02 ms 442.91 ms 75.89 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/queue-instrumentation-otel-samples

Startup times

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

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