Affects: Spring boot 3.2.5, but same with other versions as well; java 17
I have metrics and prometheus enabled, I am creating my own KafkaTemplate and setting a micrometerTagsProvider for it. And at that point the spring_kafka_template_... metrics all break, they stop, value at 0, the given tags are not shown. It doesn't matter what tag name or value i provide, or how many, behavior is the same. However, if i provide an empty Map, the metric will start working again.
KafkaTemplate also support adding static tags via KafkaTemplate#setMicrometerTags(Map). This always work and doesn't break the metric. Metric will show these static tags in all cases (even if micrometerTagsProvider is used).
Please see example here: https://github.com/HStoyanov-augglobal/kafka-metrics-springboot-bug-report/blob/main/src/main/java/bugreport/BugReportApplication.java#L33-L47
You can run a small project to test it yourself if you have access to your own kafka: https://github.com/HStoyanov-augglobal/kafka-metrics-springboot-bug-report/tree/main
Comment From: wilkinsona
Thanks for the report but this is out of Spring Boot's control. KafkaTemplate is part of Spring for Apache Kafka that is managed as a separate project.