Skip to content

Commit 2133bf5

Browse files
committed
update spring kafka
1 parent e32b309 commit 2133bf5

File tree

3 files changed

+31
-62
lines changed

3 files changed

+31
-62
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/micrometer.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,33 @@ The `record` property in both observation contexts contains the `ConsumerRecord`
119119
The sender and receiver contexts `remoteServiceName` properties are set to the Kafka `clusterId` property; this is retrieved by a `KafkaAdmin`.
120120
If, for some reason - perhaps lack of admin permissions, you cannot retrieve the cluster id, starting with version 3.1, you can set a manual `clusterId` on the `KafkaAdmin` and inject it into ``KafkaTemplate``s and listener containers.
121121
When it is `null` (default), the admin will invoke the `describeCluster` admin operation to retrieve it from the broker.
122+
123+
[[batch-listener-obs]]
124+
=== Batch Listener Observations
125+
126+
When using a batch listener, by default, no observations are created, even if a
127+
`ObservationRegistry` is present.
128+
This is because the scope of an observation is tied to the thread, and with a batch
129+
listener, there is no one-to-one mapping between an observation and a record.
130+
131+
To enable per-record observations in a batch listener, set the container factory
132+
property `recordObservationsInBatch` to `true`.
133+
134+
[source,java]
135+
----
136+
@Bean
137+
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
138+
ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
139+
ConsumerFactory<Object, Object> kafkaConsumerFactory) {
140+
141+
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
142+
configurer.configure(factory, kafkaConsumerFactory);
143+
factory.getContainerProperties().setRecordObservationsInBatch(true);
144+
return factory;
145+
}
146+
----
147+
148+
When this property is `true`, an observation will be created for each record in the
149+
batch, but the observation is not propagated to the listener method.
150+
This allows you to have visibility into the processing of each record, even within a
151+
batch context.

spring-kafka-docs/src/main/antora/modules/ROOT/pages/micrometer.adoc

Lines changed: 0 additions & 60 deletions
This file was deleted.

spring-kafka-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ More details are available in xref:kafka/headers.adoc#multi-value-header[Support
8181
=== Per-Record Observation in Batch Listeners
8282

8383
It is now possible to get an observation for each record when using a batch listener.
84-
Previously, only a single observation was created for the entire batch.
85-
See xref:micrometer.adoc#batch-listener-obs[Observability for Batch Listeners] for more information.
84+
See xref:kafka/micrometer.adoc#batch-listener-obs[Observability for Batch Listeners] for more information.

0 commit comments

Comments
 (0)