Skip to content

fix(spring-jakarta): [Queue Instrumentation 29] Set body_size on Spring Kafka consumer transaction#5325

Draft
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-otel-coexistence-cifrom
fix/queue-instrumentation-spring-kafka-body-size
Draft

fix(spring-jakarta): [Queue Instrumentation 29] Set body_size on Spring Kafka consumer transaction#5325
adinauer wants to merge 1 commit intofix/queue-instrumentation-kafka-otel-coexistence-cifrom
fix/queue-instrumentation-spring-kafka-body-size

Conversation

@adinauer
Copy link
Copy Markdown
Member

PR Stack (Queue Instrumentation)


📜 Description

Set messaging.message.body_size on the queue.process transaction created by the Spring Kafka consumer path (SentryKafkaRecordInterceptor).

  • Mirror sentry-kafka's SentryKafkaConsumerTracing: read ConsumerRecord#serializedValueSize() and, when non-negative, set SpanDataConvention.MESSAGING_MESSAGE_BODY_SIZE on the transaction.
  • Add two regression tests — positive serializedValueSize sets the attribute; the default -1 (unknown) omits it.

💡 Motivation and Context

Two first-party Kafka consumer integrations shipped in the same stack — the raw sentry-kafka helper and the Spring Kafka RecordInterceptor — were emitting different messaging schemas for the same underlying record metadata. The raw helper already set messaging.message.body_size from record.serializedValueSize(), but the Spring path never did, so customers filtering or grouping on that attribute saw inconsistent results across Spring vs. raw Kafka setups and dashboards could not rely on it being populated.

Addresses review finding F-012.

💚 How did you test it?

  • ./gradlew :sentry-spring-jakarta:test --tests "io.sentry.spring.jakarta.kafka.SentryKafkaRecordInterceptorTest" — 23/23 tests pass, including the two new body_size cases.
  • ./gradlew spotlessApply apiDump — formatting applied, no API changes (class is @ApiStatus.Internal).

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

#skip-changelog

…ng Kafka consumer transaction

The Spring Kafka consumer path (`SentryKafkaRecordInterceptor`) never set
`messaging.message.body_size`, while the raw Kafka consumer helper
(`SentryKafkaConsumerTracing`) already sets it from
`ConsumerRecord#serializedValueSize()`.

Both are first-party Kafka consumer integrations shipped in the same
stack and should emit the same messaging schema so dashboards and
queries remain consistent across Spring vs. raw Kafka setups.

Mirror the raw helper: set `SpanDataConvention.MESSAGING_MESSAGE_BODY_SIZE`
on the `queue.process` transaction when `serializedValueSize() >= 0`.
Add regression tests for both the positive and the -1 (unknown) cases.

#skip-changelog
This was referenced Apr 22, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 22, 2026

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 320.00 ms 358.56 ms 38.56 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