Automatically configure Spring Kafka's observation convention beans

This automatically registers KafkaListenerObservationConvention on the
container factory, and KafkaTemplateObservationConvention on the
Kafka template.

Closes gh-48914
This commit is contained in:
Moritz Halbritter
2026-01-20 17:29:35 +01:00
parent 697c8fe385
commit d65eb69647
6 changed files with 47 additions and 2 deletions
@@ -32,6 +32,8 @@ include-code::MyBean[]
NOTE: If the property configprop:spring.kafka.producer.transaction-id-prefix[] is defined, a javadoc:org.springframework.kafka.transaction.KafkaTransactionManager[] is automatically configured.
Also, if a javadoc:org.springframework.kafka.support.converter.RecordMessageConverter[] bean is defined, it is automatically associated to the auto-configured javadoc:org.springframework.kafka.core.KafkaTemplate[].
If there's a bean of type `KafkaTemplateObservationConvention` in the context, it is automatically registered on the `KafkaTemplate`.
[[messaging.kafka.receiving]]
@@ -52,6 +54,8 @@ If only a javadoc:org.springframework.kafka.support.converter.RecordMessageConve
TIP: A custom javadoc:org.springframework.kafka.transaction.ChainedKafkaTransactionManager[] must be marked javadoc:org.springframework.context.annotation.Primary[format=annotation] as it usually references the auto-configured javadoc:org.springframework.kafka.transaction.KafkaTransactionManager[] bean.
If there's a bean of type `KafkaListenerObservationConvention` in the context, it is automatically registered on the container factory.
[[messaging.kafka.streams]]