Skip to content

Commit

Permalink
GH-2926: Clarify docs on observablity when consuming in batches
Browse files Browse the repository at this point in the history
Resolves #2926

* Clarify docs on Observability when consuming records in batch mode in Kafka binder
  • Loading branch information
sobychacko committed Apr 29, 2024
1 parent 7845be5 commit 9cbd459
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/modules/ROOT/pages/kafka/kafka-binder/consume-batches.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Person>` and `Message<List<Person>>` 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<List<String>>`, 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.

0 comments on commit 9cbd459

Please sign in to comment.