From 9cbd45910ef1b3873070a7547b44c004efc338d8 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Mon, 29 Apr 2024 18:33:07 -0400 Subject: [PATCH] GH-2926: Clarify docs on observablity when consuming in batches Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2926 * Clarify docs on Observability when consuming records in batch mode in Kafka binder --- .../ROOT/pages/kafka/kafka-binder/consume-batches.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/modules/ROOT/pages/kafka/kafka-binder/consume-batches.adoc b/docs/modules/ROOT/pages/kafka/kafka-binder/consume-batches.adoc index bfd0e8d45..86d6866b3 100644 --- a/docs/modules/ROOT/pages/kafka/kafka-binder/consume-batches.adoc +++ b/docs/modules/ROOT/pages/kafka/kafka-binder/consume-batches.adoc @@ -32,3 +32,13 @@ Refer to the https://docs.spring.io/spring-kafka/reference/kafka/receiving-messa NOTE: When receiving `KafkaNull` objects in the batch-mode, the received list will contain a null element for the corresponding `KafkaNull` object. This is true for both `List` and `Message>` style type signatures. + +== Observability when consuming in batch mode + +When consuming records in batches, observation tracing propagation feature is not supported directly. +This is because Spring for Apache Kafka library that is used by the Kafka binder does not support tracing on batch listeners; it is only supported for record listeners. +In a batch listener, the received records could be from multiple topics/partitions and from multiple producers where adding tracing information was optional. +Since there may not be any correlations between records in the batch, the framework cannot make any assumptions about tracing them, such as providing them as a single trace ID, etc. +If you use the type signature of `Message>`, you can then get a header called `kafka_batchConvertedHeaders`, which contains a list with the same number of entries as your payload. +This list has a `Map` that contains the tracing headers. +However, it is up to the application to iterate over this properly and start an observation.