Skip to content

feat(core): Queue Instrumentation#5249

Draft
adinauer wants to merge 145 commits intomainfrom
feat/queue-instrumentation
Draft

feat(core): Queue Instrumentation#5249
adinauer wants to merge 145 commits intomainfrom
feat/queue-instrumentation

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Mar 31, 2026

PR Stack (Queue Instrumentation)


Collection PR for the Queue Instrumentation stack. Squash-merge this once all stack PRs are merged.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 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 by adinauer in #5249

Bug Fixes 🐛

  • (compose) NoSuchMethodError for LayoutCoordinates.localBoundingBoxOf$default on Compose touch dispatch with AGP 8.13 and minSdk < 24 by romtsn in #5302

Internal Changes 🔧

Deps

  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.25.2 to 2.25.4 by dependabot in #5311
  • Bump actions/cache from 5.0.4 to 5.0.5 by dependabot in #5310
  • Bump getsentry/craft from 2.25.2 to 2.25.4 by dependabot in #5309
  • Bump github/codeql-action from 4.35.1 to 4.35.2 by dependabot in #5308
  • Update Native SDK to v0.13.7 by github-actions in #5296

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

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 #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 46225de

…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>
@sentry
Copy link
Copy Markdown

sentry Bot commented Mar 31, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.40.0 (1) release

⚙️ sentry-android Build Distribution Settings

adinauer and others added 24 commits March 31, 2026 15:31
…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>
…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>
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>
… 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>
…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
adinauer added 24 commits May 5, 2026 06:22
…fka-console-sample

feat(samples): [Queue Instrumentation 15] Add opt-in Kafka console e2e coverage
…ka-system-test-runner

fix(test): [Queue Instrumentation 16] Enable Kafka profile in system runner
…fka-consumer-tracing

feat(kafka): [Queue Instrumentation 17] Add manual consumer tracing helper
…ka-sample-package

ref(samples): [Queue Instrumentation 18] Move Kafka sources into queues.kafka package
…ka-sample-autoconfig

ref(samples): [Queue Instrumentation 19] Drop Kafka auto-config exclude from Spring Boot samples
…ka-log-failures

ref(kafka): [Queue Instrumentation 20] Log Kafka instrumentation failures
…ka-preserve-baggage

fix(kafka): [Queue Instrumentation 21] Preserve third-party baggage on Kafka producer records
…fka-autoconfig-class-gate

test(spring-boot-jakarta): [Queue Instrumentation 22] Cover spring-kafka class-absence gate
…ka-context-handoff

fix(spring-jakarta): [Queue Instrumentation 23] Install Kafka context before trace setup
…ka-baggage-headers

fix(kafka): [Queue Instrumentation 24] Read all baggage headers on consumers
…ka-producer-span-cleanup

fix(kafka): [Queue Instrumentation 25] Finish producer spans on failures
…ka-producer-api-status

fix(kafka): [Queue Instrumentation 26] Mark producer interceptor experimental
…ka-record-interceptor-thread-state

fix(spring-jakarta): [Queue Instrumentation 27] Delegate Kafka record thread-state hooks
…ka-otel-coexistence-ci

test(samples): [Queue Instrumentation 28] Cover OTel Jakarta Kafka coexistence in CI
…ing-kafka-body-size

fix(spring-jakarta): [Queue Instrumentation 29] Set body_size on Spring Kafka consumer transaction
…fka-record-interceptor-lifecycle

test(spring-jakarta): [Queue Instrumentation 30] Cover Kafka record interceptor lifecycle edge cases
…ka-enqueued-time-format

fix(kafka): [Queue Instrumentation 31] Write enqueued-time header as plain decimal
…fka-auto-config-filter-otel

test(spring-boot-jakarta): [Queue Instrumentation 32] Filter OTel in Kafka auto-config negative tests
…el-messaging-mapping

fix(otel): [Queue Instrumentation 34] Fix OTel messaging span mapping correctness
fix(kafka): [Queue Instrumentation 35] Inject trace headers without real active span
…r-reflection

fix(kafka): [Queue Instrumentation 36] Avoid dropping customer interceptor
fix(spring-boot-jakarta): [Queue Instrumentation 37] Skip Kafka autoconfig for OTel agent
…le-token

fix(spring-jakarta): [Queue Instrumentation 38] Close leaked Kafka interceptor scope
…ontainer

fix(test): [Queue Instrumentation 39] Remove stale Kafka container before startup
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.

2 participants