Class MetricListener

java.lang.Object
org.apache.flink.metrics.testutils.MetricListener

public class MetricListener extends Object
A MetricListener listens metric and group registration under the provided root metric group, and stores them in an internal HashMap for fetching.
  • Field Details

  • Constructor Details

    • MetricListener

      public MetricListener()
  • Method Details

    • getMetricGroup

      public org.apache.flink.metrics.MetricGroup getMetricGroup()
      Get the root metric group of this listener. Note that only metrics and groups registered under this group will be listened.
      Returns:
      Root metric group
    • getMetric

      public <T extends org.apache.flink.metrics.Metric> Optional<T> getMetric(Class<T> metricType, String... identifier)
      Get registered Metric with identifier relative to the root metric group.

      For example, identifier of metric "myMetric" registered in group "myGroup" under root metric group can be reached by identifier ("myGroup", "myMetric")

      Parameters:
      identifier - identifier relative to the root metric group
      Returns:
      Optional registered metric
    • getMeter

      public Optional<org.apache.flink.metrics.Meter> getMeter(String... identifier)
      Get registered Meter with identifier relative to the root metric group.
      Parameters:
      identifier - identifier relative to the root metric group
      Returns:
      Optional registered meter
    • getCounter

      public Optional<org.apache.flink.metrics.Counter> getCounter(String... identifier)
      Get registered Counter with identifier relative to the root metric group.
      Parameters:
      identifier - identifier relative to the root metric group
      Returns:
      Optional registered counter
    • getHistogram

      public Optional<org.apache.flink.metrics.Histogram> getHistogram(String... identifier)
      Get registered Histogram with identifier relative to the root metric group.
      Parameters:
      identifier - identifier relative to the root metric group
      Returns:
      Optional registered histogram
    • getGauge

      public <T> Optional<org.apache.flink.metrics.Gauge<T>> getGauge(String... identifier)
      Get registered Gauge with identifier relative to the root metric group.
      Parameters:
      identifier - identifier relative to the root metric group
      Returns:
      Optional registered gauge