Search code examples
spring-bootspring-kafkaspring-cloud-streammicrometer

How to configure Micrometer KafkaClientMetrics with spring-cloud-stream


I would like to know how the io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics class (v1.5.2) can be configured. From where do I get the Consumer & Producers which are created by the underlying kafka binder. And when do I have to invoke the whole thing? (There's no autoconfiguration yet)

The io.micrometer.core.instrument.binder.kafka.KafkaConsumerMetrics class which gets autoconfigured does not register the meteres because Set<ObjectName> objs = mBeanServer.queryNames(new ObjectName(JMX_DOMAIN + ":type=" + type + ",*"), null); returns an empty set. Do I have to configure something special to make this work?

Thanks.


Solution

  • Spring Boot 2.3 automatically configures them with spring-kafka 2.5.x:

    https://github.com/spring-projects/spring-boot/blob/8abcb1b1254a9cc4b623e5af871563ff94bb15a6/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/KafkaMetricsAutoConfiguration.java#L56-L64

    https://github.com/spring-projects/spring-boot/issues/21008

    Micrometer has deprecated the old JMX scraping meters.