Package org.apache.kafka.common.metrics
Class KafkaMetric
java.lang.Object
org.apache.kafka.common.metrics.KafkaMetric
- All Implemented Interfaces:
Metric
-
Constructor Summary
ConstructorsConstructorDescriptionKafkaMetric(Object lock, MetricName metricName, MetricValueProvider<?> valueProvider, MetricConfig config, org.apache.kafka.common.utils.Time time) Create a metric to monitor an object that implements MetricValueProvider. -
Method Summary
Modifier and TypeMethodDescriptionconfig()Get the configuration of this metric.voidconfig(MetricConfig config) Set the metric config.booleanThe method determines if the metric value provider is of type Measurable.Get the underlying metric provider, which should be aMeasurableGet the metric nameTake the metric and return the value, which could be aMeasurableor aGauge
-
Constructor Details
-
KafkaMetric
public KafkaMetric(Object lock, MetricName metricName, MetricValueProvider<?> valueProvider, MetricConfig config, org.apache.kafka.common.utils.Time time) Create a metric to monitor an object that implements MetricValueProvider.- Parameters:
lock- The lock used to prevent race conditionmetricName- The name of the metricvalueProvider- The metric value provider associated with this metricconfig- The configuration of the metrictime- The time instance to use with the metrics
-
-
Method Details
-
config
Get the configuration of this metric. This is supposed to be used by server only.- Returns:
- Return the config of this metric
-
metricName
Get the metric name- Specified by:
metricNamein interfaceMetric- Returns:
- Return the name of this metric
-
metricValue
Take the metric and return the value, which could be aMeasurableor aGauge- Specified by:
metricValuein interfaceMetric- Returns:
- Return the metric value
- Throws:
IllegalStateException- if the underlying metric is not aMeasurableor aGauge.
-
isMeasurable
public boolean isMeasurable()The method determines if the metric value provider is of type Measurable.- Returns:
- true if the metric value provider is of type Measurable, false otherwise.
-
measurable
Get the underlying metric provider, which should be aMeasurable- Returns:
- Return the metric provider
- Throws:
IllegalStateException- if the underlying metric is not aMeasurable.
-
config
Set the metric config. This is supposed to be used by server only.- Parameters:
config- configuration for this metrics
-