Interface MetricsReporter

All Superinterfaces:
AutoCloseable, Configurable, Reconfigurable
All Known Implementing Classes:
JmxReporter

public interface MetricsReporter
extends Reconfigurable, AutoCloseable
A plugin interface to allow things to listen as new metrics are created so they can be reported.

Implement ClusterResourceListener to receive cluster metadata once it's available. Please see the class documentation for ClusterResourceListener for more information.

  • Method Summary

    Modifier and Type Method Description
    void close()
    Called when the metrics repository is closed.
    default void contextChange​(MetricsContext metricsContext)
    Sets the context labels for the service or library exposing metrics.
    void init​(List<KafkaMetric> metrics)
    This is called when the reporter is first registered to initially register all existing metrics
    void metricChange​(KafkaMetric metric)
    This is called whenever a metric is updated or added
    void metricRemoval​(KafkaMetric metric)
    This is called whenever a metric is removed
    default Set<String> reconfigurableConfigs()
    Returns the names of configs that may be reconfigured.
    default void reconfigure​(Map<String,​?> configs)
    Reconfigures this instance with the given key-value pairs.
    default void validateReconfiguration​(Map<String,​?> configs)
    Validates the provided configuration.

    Methods inherited from interface org.apache.kafka.common.Configurable

    configure
  • Method Details

    • init

      void init​(List<KafkaMetric> metrics)
      This is called when the reporter is first registered to initially register all existing metrics
      Parameters:
      metrics - All currently existing metrics
    • metricChange

      void metricChange​(KafkaMetric metric)
      This is called whenever a metric is updated or added
      Parameters:
      metric -
    • metricRemoval

      void metricRemoval​(KafkaMetric metric)
      This is called whenever a metric is removed
      Parameters:
      metric -
    • close

      void close()
      Called when the metrics repository is closed.
      Specified by:
      close in interface AutoCloseable
    • reconfigurableConfigs

      default Set<String> reconfigurableConfigs()
      Description copied from interface: Reconfigurable
      Returns the names of configs that may be reconfigured.
      Specified by:
      reconfigurableConfigs in interface Reconfigurable
    • validateReconfiguration

      default void validateReconfiguration​(Map<String,​?> configs) throws ConfigException
      Description copied from interface: Reconfigurable
      Validates the provided configuration. The provided map contains all configs including any reconfigurable configs that may be different from the initial configuration. Reconfiguration will be not performed if this method throws any exception.
      Specified by:
      validateReconfiguration in interface Reconfigurable
      Throws:
      ConfigException - if the provided configs are not valid. The exception message from ConfigException will be returned to the client in the AlterConfigs response.
    • reconfigure

      default void reconfigure​(Map<String,​?> configs)
      Description copied from interface: Reconfigurable
      Reconfigures this instance with the given key-value pairs. The provided map contains all configs including any reconfigurable configs that may have changed since the object was initially configured using Configurable.configure(Map). This method will only be invoked if the configs have passed validation using Reconfigurable.validateReconfiguration(Map).
      Specified by:
      reconfigure in interface Reconfigurable
    • contextChange

      @Evolving default void contextChange​(MetricsContext metricsContext)
      Sets the context labels for the service or library exposing metrics. This will be called before init(List) and may be called anytime after that.
      Parameters:
      metricsContext - the metric context