feat(spring-jakarta): [Queue Instrumentation 3] Add Kafka producer instrumentation#5254
Draft
adinauer wants to merge 2 commits intofeat/queue-instrumentation-samplefrom
Draft
feat(spring-jakarta): [Queue Instrumentation 3] Add Kafka producer instrumentation#5254adinauer wants to merge 2 commits intofeat/queue-instrumentation-samplefrom
adinauer wants to merge 2 commits intofeat/queue-instrumentation-samplefrom
Conversation
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>
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Deps
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
|
This was referenced Apr 1, 2026
Sentry Build Distribution
|
8 tasks
Contributor
Performance metrics 🚀
|
This was referenced Apr 1, 2026
Merged
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
Add Kafka producer instrumentation to
sentry-spring-jakarta:SentryKafkaProducerWrapper— extendsKafkaTemplate, overridesdoSendto createqueue.publishspans for all send variants. Injectssentry-trace,baggage, andsentry-task-enqueued-timeheaders into Kafka record headers for distributed tracing and receive latency calculation. Span finishes asynchronously in theCompletableFuture.whenCompletecallback.SentryKafkaProducerBeanPostProcessor— automatically wrapsKafkaTemplatebeans inSentryKafkaProducerWrapper. Follows the same pattern asSentryCacheBeanPostProcessor.Key design decisions:
doSend(protected) rather thansend(ProducerRecord)because allsendvariants (send(topic, value),send(topic, key, value),sendDefault(value), etc.) route throughobserveSend→doSend, not throughsend(ProducerRecord)SentryOptions.isEnableQueueTracing()— no spans created when disabled💡 Motivation and Context
PR 3 in the Queue Instrumentation stack. Adds the producer-side instrumentation that creates
queue.publishspans and injects trace headers for distributed tracing to the consumer side (PR 4).💚 How did you test it?
./gradlew :sentry-spring-jakarta:test --tests="*SentryKafkaProducer*"— 8 tests pass📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
SentryKafkaRecordInterceptor)