Skip to content

feat(spring-jakarta): [Queue Instrumentation 4] Add Kafka consumer instrumentation#5255

Draft
adinauer wants to merge 2 commits intofeat/queue-instrumentation-producerfrom
feat/queue-instrumentation-consumer
Draft

feat(spring-jakarta): [Queue Instrumentation 4] Add Kafka consumer instrumentation#5255
adinauer wants to merge 2 commits intofeat/queue-instrumentation-producerfrom
feat/queue-instrumentation-consumer

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 1, 2026

PR Stack (Queue Instrumentation)


📜 Description

Add Kafka consumer instrumentation to sentry-spring-jakarta:

  • SentryKafkaRecordInterceptor — implements RecordInterceptor to create queue.process transactions for incoming Kafka records. Forks scopes per record for isolation (ISentryLifecycleToken lifecycle). 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.
  • SentryKafkaConsumerBeanPostProcessor — registers the interceptor on ConcurrentKafkaListenerContainerFactory beans.

💡 Motivation and Context

Consumer-side instrumentation is needed to create process transactions and continue the distributed trace from the producer.

💚 How did you test it?

Unit tests for SentryKafkaRecordInterceptor and SentryKafkaConsumerBeanPostProcessor.

📝 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 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>
@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 ✨

Spring Jakarta

  • [Queue Instrumentation 4] Add Kafka consumer instrumentation by adinauer in #5255
  • [Queue Instrumentation 3] Add Kafka producer instrumentation by adinauer in #5254

Other

  • (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
  • 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 1f00027

@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 250.50 ms 320.04 ms 69.54 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/queue-instrumentation-producer

Startup times

Revision Plain With Sentry Diff
d439efd 323.43 ms 384.17 ms 60.73 ms

App size

Revision Plain With Sentry Diff
d439efd 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