Package org.apache.flink.connector.kafka
Class MetricUtil
java.lang.Object
org.apache.flink.connector.kafka.MetricUtil
Collection of methods to interact with Kafka's client metric system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.kafka.common.MetricgetKafkaMetric(Map<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric> metrics, String metricGroup, String metricName) Tries to find the KafkaMetricin the provided metrics.static org.apache.kafka.common.MetricgetKafkaMetric(Map<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric> metrics, java.util.function.Predicate<Map.Entry<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric>> filter) Tries to find the KafkaMetricin the provided metrics matching a given filter.static voidsync(org.apache.kafka.common.Metric from, org.apache.flink.metrics.Counter to) Ensures that the counter has the same value as the given Kafka metric.
-
Constructor Details
-
MetricUtil
public MetricUtil()
-
-
Method Details
-
getKafkaMetric
public static org.apache.kafka.common.Metric getKafkaMetric(Map<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric> metrics, String metricGroup, String metricName) Tries to find the KafkaMetricin the provided metrics.- Returns:
Metricwhich exposes continuous updates- Throws:
IllegalStateException- if the metric is not part of the provided metrics
-
getKafkaMetric
public static org.apache.kafka.common.Metric getKafkaMetric(Map<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric> metrics, java.util.function.Predicate<Map.Entry<org.apache.kafka.common.MetricName, ? extends org.apache.kafka.common.Metric>> filter) Tries to find the KafkaMetricin the provided metrics matching a given filter.- Returns:
Metricwhich exposes continuous updates- Throws:
IllegalStateException- if no metric matches the given filter
-
sync
public static void sync(org.apache.kafka.common.Metric from, org.apache.flink.metrics.Counter to) Ensures that the counter has the same value as the given Kafka metric.Do not use this method for every record because
Metric.metricValue()is an expensive operation.- Parameters:
from- Kafka'sMetricto queryto-Counterto write the value to
-