Skip to content

feat(spring-jakarta): [Queue Instrumentation 3] Add Kafka producer instrumentation#5254

Draft
adinauer wants to merge 2 commits intofeat/queue-instrumentation-samplefrom
feat/queue-instrumentation-producer
Draft

feat(spring-jakarta): [Queue Instrumentation 3] Add Kafka producer instrumentation#5254
adinauer wants to merge 2 commits intofeat/queue-instrumentation-samplefrom
feat/queue-instrumentation-producer

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 1, 2026

PR Stack (Queue Instrumentation)


📜 Description

Add Kafka producer instrumentation to sentry-spring-jakarta:

  • SentryKafkaProducerWrapper — 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.
  • SentryKafkaProducerBeanPostProcessor — automatically wraps KafkaTemplate beans.

💡 Motivation and Context

Producer-side instrumentation is needed to create publish spans and inject trace propagation headers into Kafka messages.

💚 How did you test it?

Unit tests for SentryKafkaProducerWrapper and SentryKafkaProducerBeanPostProcessor.

📝 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.

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>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

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


New Features ✨

  • (core) [Queue Instrumentation 1] Add enableQueueTracing option and messaging span data conventions by adinauer in #5250
  • (samples) [Queue Instrumentation 2] Add Kafka to Spring Boot 3 sample app by adinauer in #5253
  • (spring-jakarta) [Queue Instrumentation 3] Add Kafka producer instrumentation by adinauer in #5254
  • Add strict trace continuation support by giortzisg in #5136
  • Sync file attachments to native by bitsandfoxes in #5211

Internal Changes 🔧

Deps

  • Bump requests from 2.32.4 to 2.33.0 in the uv group across 1 directory by dependabot in #5237
  • Bump github/codeql-action from 4.32.6 to 4.35.1 by dependabot in #5243

Other

  • Add THIRD_PARTY_NOTICES.md for vendored third-party code by markushi in #5186

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 5049ffc

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 1, 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 1, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 323.43 ms 384.17 ms 60.73 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