Class MetricListener
java.lang.Object
org.apache.flink.metrics.testutils.MetricListener
A MetricListener listens metric and group registration under the provided root metric group, and
stores them in an internal HashMap for fetching.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.apache.flink.metrics.Counter>getCounter(String... identifier) Get registeredCounterwith identifier relative to the root metric group.<T> Optional<org.apache.flink.metrics.Gauge<T>>Get registeredGaugewith identifier relative to the root metric group.Optional<org.apache.flink.metrics.Histogram>getHistogram(String... identifier) Get registeredHistogramwith identifier relative to the root metric group.Optional<org.apache.flink.metrics.Meter>Get registeredMeterwith identifier relative to the root metric group.<T extends org.apache.flink.metrics.Metric>
Optional<T>Get registeredMetricwith identifier relative to the root metric group.org.apache.flink.metrics.MetricGroupGet the root metric group of this listener.
-
Field Details
-
DELIMITER
- See Also:
-
ROOT_METRIC_GROUP_NAME
- See Also:
-
-
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 registeredMetricwith 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
Get registeredMeterwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered meter
-
getCounter
Get registeredCounterwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered counter
-
getHistogram
Get registeredHistogramwith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered histogram
-
getGauge
Get registeredGaugewith identifier relative to the root metric group.- Parameters:
identifier- identifier relative to the root metric group- Returns:
- Optional registered gauge
-