In what version(s) of Spring for Apache Kafka are you seeing this issue?
4.0.1, 4.0.0, 3.5.6
Describe the bug
When configuring @KafkaListener with @RetryableTopic the metrics spring.kakfa.listener is being incremented twice.
The problem seems to be on https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java#L2822
When the retryableTopic is disabled the listener class is RecordMessagingMessageListenerAdapter and the metric register on line will be ignored
but when I have retryableTopic enabled the listener class is KafkaBackoffAwareMessageListenerAdapter and this one delegates to RecordMessagingMessageListenerAdapter
The problem is when the method isListenerAdapterObservationAware check returns false because, as I said, listener is of class KafkaBackoffAwareMessageListenerAdapter and the metric will be incremented twice.
In my mind in this case should also be ignored because KafkaBackoffAwareMessageListenerAdapter delegates to RecordMessagingMessageListenerAdapter.
The metric is registered twice because the observation is the same in both instances and both are calling observation.stop()
To Reproduce
https://github.com/victorpasqualino/spring-kafka-duplicated-metric
Expected behavior
I was expecting to the metric be incremented only once
Sample
https://github.com/victorpasqualino/spring-kafka-duplicated-metric
Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.
In what version(s) of Spring for Apache Kafka are you seeing this issue?
4.0.1, 4.0.0, 3.5.6
Describe the bug
When configuring @KafkaListener with @RetryableTopic the metrics spring.kakfa.listener is being incremented twice.
The problem seems to be on https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java#L2822
When the retryableTopic is disabled the listener class is RecordMessagingMessageListenerAdapter and the metric register on line will be ignored
but when I have retryableTopic enabled the listener class is KafkaBackoffAwareMessageListenerAdapter and this one delegates to RecordMessagingMessageListenerAdapter
The problem is when the method isListenerAdapterObservationAware check returns false because, as I said, listener is of class KafkaBackoffAwareMessageListenerAdapter and the metric will be incremented twice.
In my mind in this case should also be ignored because KafkaBackoffAwareMessageListenerAdapter delegates to RecordMessagingMessageListenerAdapter.
The metric is registered twice because the observation is the same in both instances and both are calling observation.stop()
To Reproduce
https://github.com/victorpasqualino/spring-kafka-duplicated-metric
Expected behavior
I was expecting to the metric be incremented only once
Sample
https://github.com/victorpasqualino/spring-kafka-duplicated-metric
Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.