Class KafkaMetricsSupport<C>

java.lang.Object
org.springframework.kafka.core.KafkaMetricsSupport<C>
Type Parameters:
C - the Kafka Client type.
Direct Known Subclasses:
KafkaStreamsMicrometerListener, MicrometerConsumerListener, MicrometerProducerListener

public abstract class KafkaMetricsSupport<C> extends Object
An abstract class to manage KafkaClientMetrics.
Since:
3.3
Author:
Artem Bilan
See Also:
  • KafkaClientMetrics
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final io.micrometer.core.instrument.MeterRegistry
     
    protected final ScheduledExecutorService
     
    protected final List<io.micrometer.core.instrument.Tag>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry)
    Construct an instance with the provided registry.
    protected
    KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags)
    Construct an instance with the provided MeterRegistry and tags.
    protected
    KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags, TaskScheduler taskScheduler)
    Construct an instance with the provided MeterRegistry, tags and TaskScheduler.
    protected
    KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, TaskScheduler taskScheduler)
    Construct an instance with the provided MeterRegistry and TaskScheduler.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    bindClient(String id, C client)
    Bind metrics for the Apache Kafka client with provided id.
    protected io.micrometer.core.instrument.binder.MeterBinder
    createClientMetrics(C client, List<io.micrometer.core.instrument.Tag> tags)
    Create a io.micrometer.core.instrument.binder.kafka.KafkaMetrics instance for the provided Kafka client and metric tags.
    protected final void
    unbindClient(String id, C client)
    Unbind a io.micrometer.core.instrument.binder.kafka.KafkaMetrics for the provided Kafka client.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • meterRegistry

      protected final io.micrometer.core.instrument.MeterRegistry meterRegistry
    • tags

      protected final List<io.micrometer.core.instrument.Tag> tags
    • scheduler

      @Nullable protected final ScheduledExecutorService scheduler
  • Constructor Details

    • KafkaMetricsSupport

      protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry)
      Construct an instance with the provided registry.
      Parameters:
      meterRegistry - the registry.
    • KafkaMetricsSupport

      protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, TaskScheduler taskScheduler)
      Construct an instance with the provided MeterRegistry and TaskScheduler.
      Parameters:
      meterRegistry - the registry.
      taskScheduler - the task scheduler.
    • KafkaMetricsSupport

      protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags)
      Construct an instance with the provided MeterRegistry and tags.
      Parameters:
      meterRegistry - the registry.
      tags - the tags.
    • KafkaMetricsSupport

      protected KafkaMetricsSupport(io.micrometer.core.instrument.MeterRegistry meterRegistry, List<io.micrometer.core.instrument.Tag> tags, TaskScheduler taskScheduler)
      Construct an instance with the provided MeterRegistry, tags and TaskScheduler.
      Parameters:
      meterRegistry - the registry.
      tags - the tags.
      taskScheduler - the task scheduler.
  • Method Details

    • bindClient

      protected final void bindClient(String id, C client)
      Bind metrics for the Apache Kafka client with provided id.
      Parameters:
      id - the unique identifier for the client to manage in store.
      client - the Kafka client instance to bind.
    • createClientMetrics

      protected io.micrometer.core.instrument.binder.MeterBinder createClientMetrics(C client, List<io.micrometer.core.instrument.Tag> tags)
      Create a io.micrometer.core.instrument.binder.kafka.KafkaMetrics instance for the provided Kafka client and metric tags. By default, this factory is aware of Consumer, Producer and AdminClient types. For other use-case this method can be overridden.
      Parameters:
      client - the client to create a io.micrometer.core.instrument.binder.kafka.KafkaMetrics instance for.
      tags - the tags for the io.micrometer.core.instrument.binder.kafka.KafkaMetrics.
      Returns:
      the io.micrometer.core.instrument.binder.kafka.KafkaMetrics.
    • unbindClient

      protected final void unbindClient(String id, C client)
      Unbind a io.micrometer.core.instrument.binder.kafka.KafkaMetrics for the provided Kafka client.
      Parameters:
      id - the unique identifier for the client to manage in store.
      client - the Kafka client instance to unbind.