agentleFS
SentryKnown publishergetsentry/sentry-java/.cursor/rules/queues.mdc

sentry-java / rules

Cursor rule1.4k starsChanged 7 months agoMITView on GitHub

Sentry Queues module and Java SDK queue tracing

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the getsentry/sentry-java repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about getsentry/sentry-java

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub (18 times).

On GitHub · 18

13 more on GitHub

The file

Files
queues.mdc
---
alwaysApply: false
description: Sentry Queues module and Java SDK queue tracing
---
# Sentry Queues and Java SDK Queue Tracing

## Product model

Sentry Queues is built from tracing data. SDKs mark queue work with queue-specific span operations and messaging span data so Sentry can identify producers, consumers, destinations, latency, and failures.

The important concepts are:
- `queue.publish`: a span for enqueueing/publishing a message to a queue or topic.
- `queue.process`: a transaction for processing a dequeued message.
- Messaging span data, especially:
  - `messaging.system` (for example `kafka`)
  - `messaging.destination.name` (queue/topic name)
  - `messaging.message.id`
  - `messaging.message.retry.count`
  - `messaging.message.body.size`
  - `messaging.message.envelope.size`
  - `messaging.message.receive.latency`
- Distributed tracing headers (`sentry-trace` and `baggage`) link producer-side work to consumer-side processing.
- Queue receive latency is the time a message spent waiting between publish/enqueue and processing. For Java Kafka, this comes from the `sentry-task-enqueued-time` header that the producer writes and the consumer reads.

The Queues UI is not backed by a separate Java event type. The Java SDK contributes data through spans/transactions with the expected operations, trace context, statuses, and messaging attributes.

## Java SDK implementation

Queue tracing is opt-in. `SentryOptions.isEnableQueueTracing()` defaults to `false` and can be enabled with `setEnableQueueTracing(true)` or external config key `enable-queue-tracing` (`sentry.enable-queue-tracing` in Spring Boot). Captured queue spans/transactions still depend on tracing being enabled and sampled.

Kafka support lives in `sentry-kafka`:
- `SentryKafkaProducer.wrap(Producer)` wraps Kafka `Producer.send(...)` calls.
  - Creates a `queue.publish` child span when there is an active span.
  - Sets `messaging.system=kafka` and `messaging.destination.name=<topic>`.
  - Injects `sentry-trace`, `baggage`, and `sentry-task-enqueued-time` headers.
  - Still injects tracing/enqueued-time headers when queue tracing is enabled but there is no active span, so background producers can link to consumers.
  - Finishes the span from the Kafka callback with `OK` or `INTERNAL_ERROR`.
- `SentryKafkaConsumerTracing.withTracing(record, callback)` is the manual raw-Kafka consumer helper.
  - Forks root scopes for the processing lifecycle and makes them current.
  - Continues the trace from Kafka headers.
  - Starts a `queue.process` transaction bound to scope when tracing is enabled.
  - Sets Kafka messaging data, body size, retry count, and receive latency when available.
  - Finishes with `OK` or `INTERNAL_ERROR` and never lets instrumentation failures break customer processing.

Spring Kafka support lives in `sentry-spring`, `sentry-spring-jakarta`, and `sentry-spring-7`:
- `SentryKafkaProducerBeanPostProcessor` installs a producer post-processor on `DefaultKafkaProducerFactory` and wraps created producers with `SentryKafkaProducer.wrap(...)`.
- `SentryKafkaConsumerBeanPostProcessor` installs `SentryKafkaRecordInterceptor` on listener container factories.
- `SentryKafkaRecordInterceptor` starts/finishes `queue.process` transactions around listener processing, continues traces from headers, forks scopes for the record lifecycle, and preserves any existing delegate interceptor.
- Spring Boot auto-configuration registers both post-processors only when Spring Kafka and `sentry-kafka` are present and `sentry.enable-queue-tracing=true`.
- Spring Boot queue auto-configuration is disabled when Sentry OpenTelemetry integration classes are present to avoid duplicate Kafka instrumentation.

## Trace origins and suppression

Queue instrumentation sets span origins so it can be identified and suppressed with `ignoredSpanOrigins`:
- Raw Kafka producer: `auto.queue.kafka.producer`
- Raw Kafka consumer helper: `manual.queue.kafka.consumer`
- Spring Kafka producer: `auto.queue.spring.kafka.producer`, `auto.queue.spring_jakarta.kafka.producer`, `auto.queue.spring7.kafka.producer`
- Spring Kafka consumer: `auto.queue.spring.kafka.consumer`, `auto.queue.spring_jakarta.kafka.consumer`, `auto.queue.spring7.kafka.consumer`

## Files to inspect when changing queue tracing

- Core option and conventions:
  - `sentry/src/main/java/io/sentry/SentryOptions.java`
  - `sentry/src/main/java/io/sentry/ExternalOptions.java`
  - `sentry/src/main/java/io/sentry/SpanDataConvention.java`
- Raw Kafka:
  - `sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaProducer.java`
  - `sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaConsumerTracing.java`
  - `sentry-kafka/src/test/kotlin/io/sentry/kafka/*Test.kt`
- Spring Kafka:
  - `sentry-spring*/src/main/java/io/sentry/**/kafka/*`
  - `sentry-spring*/src/test/kotlin/io/sentry/**/kafka/*Test.kt`
  - `sentry-spring-boot*/src/main/java/io/sentry/**/SentryAutoConfiguration.java`
  - `sentry-spring-boot*/src/test/kotlin/io/sentry/**/SentryKafkaAutoConfigurationTest.kt`

## Related rules

Also fetch:
- `options` when changing `enableQueueTracing` or configuration surfaces.
- `scopes` when changing consumer scope forking/lifecycle.
- `opentelemetry` when changing coexistence with OTel auto-instrumentation.
- `api` when changing public Kafka APIs or option methods.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.