| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
MetricConfig | config()Get the configuration of this metric. |
void | config(MetricConfig config)Set the metric config. |
boolean | isMeasurable()The method determines if the metric value provider is of type Measurable. |
Measurable | measurable()Get the underlying metric provider, which should be a Measurable |
double | measurableValue(long timeMs)Take the metric and return the value, where the underlying metric provider should be a Measurable |
MetricName | metricName()Get the metric name |
Object | metricValue()Take the metric and return the value, which could be a Measurable or a Gauge |
public KafkaMetric(Object lock, MetricName metricName, MetricValueProvider<?> valueProvider, MetricConfig config, org.apache.kafka.common.utils.Time time)
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 metricspublic MetricConfig config()
public MetricName metricName()
metricName in interface Metricpublic Object metricValue()
Measurable or a GaugemetricValue in interface MetricIllegalStateException - if the underlying metric is not a Measurable or a Gauge.public boolean isMeasurable()
public Measurable measurable()
MeasurableIllegalStateException - if the underlying metric is not a Measurable.public double measurableValue(long timeMs)
MeasurabletimeMs - The time that this metric is takenpublic void config(MetricConfig config)
config - configuration for this metrics