Class KafkaEventObserver


  • @ApplicationScoped
    public class KafkaEventObserver
    extends Object
    Observer to create and register KafkaClientMetrics. This observer uses only classes from "kafka-clients" and none from "kafka-streams". Must be separated from KafkaStreamsEventObserver, because they use different dependencies and if only kafka-client is used, the classes from kafka-streams aren't loaded.
    • Field Detail

      • registry

        final io.micrometer.core.instrument.MeterRegistry registry
      • clientMetrics

        Map<Object,​io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics> clientMetrics
    • Constructor Detail

      • KafkaEventObserver

        public KafkaEventObserver()
    • Method Detail

      • consumerCreated

        public void consumerCreated​(@Observes
                                    org.apache.kafka.clients.consumer.Consumer<?,​?> consumer)
        Manage bind/close of KafkaClientMetrics for the specified Consumer. If the consumer has not been seen before, it will be bound to the Micrometer registry and instrumented using a Kafka MeterBinder. If the consumer has been seen before, the MeterBinder will be closed.
        Parameters:
        consumer - Observed Kafka Consumer
      • producerCreated

        public void producerCreated​(@Observes
                                    org.apache.kafka.clients.producer.Producer<?,​?> producer)
        Manage bind/close of KafkaClientMetrics for the specified Producer. If the producer has not been seen before, it will be bound to the Micrometer registry and instrumented using a Kafka MeterBinder. If the producer has been seen before, the MeterBinder will be closed.
        Parameters:
        producer - Observed Kafka Producer