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
Conversation
…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
Draft
Draft
Draft
Draft
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Queue Instrumentation)
📜 Description
Set
messaging.message.body_sizeon thequeue.processtransaction created by the Spring Kafka consumer path (SentryKafkaRecordInterceptor).sentry-kafka'sSentryKafkaConsumerTracing: readConsumerRecord#serializedValueSize()and, when non-negative, setSpanDataConvention.MESSAGING_MESSAGE_BODY_SIZEon the transaction.serializedValueSizesets 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-kafkahelper and the Spring KafkaRecordInterceptor— were emitting different messaging schemas for the same underlying record metadata. The raw helper already setmessaging.message.body_sizefromrecord.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 newbody_sizecases../gradlew spotlessApply apiDump— formatting applied, no API changes (class is@ApiStatus.Internal).📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#skip-changelog