Draft
Conversation
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Queue Instrumentation ([#5249](https://github.com/getsentry/sentry-java/pull/5249))If none of the above apply, you can opt out of this check by adding |
…ventions Add enableQueueTracing boolean to SentryOptions (default false) and ExternalOptions (nullable Boolean) with merge support. Add messaging.* keys to SpanDataConvention for queue instrumentation span data. Co-Authored-By: Claude <noreply@anthropic.com>
📲 Install BuildsAndroid
|
8 tasks
…e app Add spring-kafka dependency and a simple Kafka producer/consumer setup behind a 'kafka' Spring profile. Includes a REST endpoint to produce messages and a KafkaListener that consumes them. Kafka auto-configuration is excluded by default and only activated when the 'kafka' profile is enabled. Co-Authored-By: Claude <noreply@anthropic.com>
Add SentryKafkaProducerWrapper that overrides doSend to create queue.publish spans for all KafkaTemplate send operations. Injects sentry-trace, baggage, and sentry-task-enqueued-time headers for distributed tracing and receive latency calculation. Add SentryKafkaProducerBeanPostProcessor to automatically wrap KafkaTemplate beans. Co-Authored-By: Claude <noreply@anthropic.com>
Add SentryKafkaRecordInterceptor that creates queue.process transactions for incoming Kafka records. Forks scopes per record, extracts sentry-trace and baggage headers for distributed tracing via continueTrace, and calculates messaging.message.receive.latency from the enqueued-time header. Composes with existing RecordInterceptor via delegation. Span lifecycle is managed through success/failure callbacks. Add SentryKafkaConsumerBeanPostProcessor to register the interceptor on ConcurrentKafkaListenerContainerFactory beans. Co-Authored-By: Claude <noreply@anthropic.com>
Register SentryKafkaProducerBeanPostProcessor and SentryKafkaConsumerBeanPostProcessor when spring-kafka is on the classpath and sentry.enable-queue-tracing=true. Follows the same pattern as SentryCacheConfiguration. Co-Authored-By: Claude <noreply@anthropic.com>
Add KafkaQueueSystemTest with e2e tests for: - Producer endpoint creates queue.publish span - Consumer creates queue.process transaction - Distributed tracing (producer and consumer share same trace) - Messaging attributes on publish span and process transaction Also add produceKafkaMessage to RestTestClient and enable sentry.enable-queue-tracing in the kafka profile properties. Requires a running Kafka broker at localhost:9092 and the sample app started with --spring.profiles.active=kafka. Co-Authored-By: Claude <noreply@anthropic.com>
Force-pushing a stack branch can cause GitHub to auto-merge or auto-close other PRs in the stack. Add explicit guidance to never use --force, --force-with-lease, or amend+push on stack branches.
…sample apps Add Kafka queue tracing support to both the OTel agent and agentless Spring Boot 3 sample applications. Each sample gets a KafkaController for producing messages and a KafkaConsumer listener, activated via the 'kafka' Spring profile. Kafka auto-configuration is excluded by default and only enabled when the kafka profile is active.
…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.
…oducerInterceptor Replace the KafkaTemplate subclass approach with a Kafka-native ProducerInterceptor. The BeanPostProcessor now sets the interceptor on the existing KafkaTemplate instead of replacing the bean, which preserves any custom configuration on the template. Existing customer interceptors are composed using Spring's CompositeProducerInterceptor. If reflection fails to read the existing interceptor, a warning is logged. Co-Authored-By: Claude <noreply@anthropic.com>
…strumentation-consumer
…rning log Update SentryKafkaRecordInterceptor and its test to reference SentryProducerInterceptor instead of the removed SentryKafkaProducerWrapper. Add a warning log in SentryKafkaConsumerBeanPostProcessor when reflection fails to read the existing RecordInterceptor, so users know their custom interceptor may not be chained. Co-Authored-By: Claude <noreply@anthropic.com>
…strumentation-autoconfig
…instrumentation-e2e
…entation-otel-samples
…-instrumentation-otel-dedup
TransactionContext constructor requires ScopesAdapter.getOptions() to be non-null for thread checker access. Add initForTest/close to ensure Sentry is properly initialized during tests. Co-Authored-By: Claude <noreply@anthropic.com>
…strumentation-consumer
… ordering Add initForTest/close to SentryKafkaRecordInterceptorTest to fix NPE from TransactionContext constructor requiring initialized Sentry. Regenerate API file to fix alphabetical ordering of SentryProducerInterceptor entry. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Apr 22, 2026
Open
This was referenced Apr 29, 2026
…tions feat(core): [Queue Instrumentation 1] Add enableQueueTracing option and messaging span data conventions
…mple feat(samples): [Queue Instrumentation 2] Add Kafka to Spring Boot 3 sample app
…oducer feat(spring-jakarta): [Queue Instrumentation 3] Add Kafka producer instrumentation
…nsumer feat(spring-jakarta): [Queue Instrumentation 4] Add Kafka consumer instrumentation
…toconfig feat(spring-boot-jakarta): [Queue Instrumentation 5] Add Kafka queue auto-configuration
test(samples): [Queue Instrumentation 6] Add Kafka queue system tests
…el-samples feat(samples): [Queue Instrumentation 7] Add Kafka to Spring Boot 3 OTel sample apps
…l-dedup fix(spring-boot-jakarta): [Queue Instrumentation 8] Disable Sentry Kafka spans when OTel is active
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5865051 | 319.74 ms | 365.60 ms | 45.86 ms |
| cf708bd | 408.35 ms | 458.98 ms | 50.63 ms |
| b750b96 | 408.98 ms | 480.32 ms | 71.34 ms |
| 1df7eb6 | 397.04 ms | 429.64 ms | 32.60 ms |
| 9ea89e8 | 308.06 ms | 358.16 ms | 50.10 ms |
| 319f256 | 315.96 ms | 372.96 ms | 57.00 ms |
| c8125f3 | 383.82 ms | 441.66 ms | 57.84 ms |
| f064536 | 327.04 ms | 405.35 ms | 78.31 ms |
| b3d8889 | 420.46 ms | 453.71 ms | 33.26 ms |
| f064536 | 335.52 ms | 408.79 ms | 73.27 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5865051 | 0 B | 0 B | 0 B |
| cf708bd | 1.58 MiB | 2.11 MiB | 539.71 KiB |
| b750b96 | 1.58 MiB | 2.10 MiB | 533.19 KiB |
| 1df7eb6 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 9ea89e8 | 1.58 MiB | 2.28 MiB | 716.23 KiB |
| 319f256 | 1.58 MiB | 2.19 MiB | 619.79 KiB |
| c8125f3 | 1.58 MiB | 2.10 MiB | 532.32 KiB |
| f064536 | 1.58 MiB | 2.20 MiB | 633.90 KiB |
| b3d8889 | 1.58 MiB | 2.10 MiB | 535.07 KiB |
| f064536 | 1.58 MiB | 2.20 MiB | 633.90 KiB |
…eadlocal-cleanup fix(spring-jakarta): [Queue Instrumentation 9] Clean up stale ThreadLocal context in Kafka consumer interceptor
…t-scopes fix(spring-jakarta): [Queue Instrumentation 10] Fork root scopes and skip when OTel is active in Kafka consumer
…ducer-guard fix(spring-jakarta): [Queue Instrumentation 11] Guard entire span lifecycle in Kafka producer interceptor
…ry-count fix(spring-jakarta): [Queue Instrumentation 12] Add Kafka retry count attribute
…ueued-time-seconds fix(spring-jakarta): [Queue Instrumentation 13] Align enqueue time with Python
…fka-module ref(kafka): [Queue Instrumentation 14] Extract sentry-kafka module
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)
Collection PR for the Queue Instrumentation stack. Squash-merge this once all stack PRs are merged.