|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.kafka.common.metrics.Metrics
public class Metrics
A registry of sensors and metrics.
A metric is a named, numerical measurement. A sensor is a handle to record numerical measurements as they occur. Each Sensor has zero or more associated metrics. For example a Sensor might represent message sizes and we might associate with this sensor a metric for the average, maximum, or other statistics computed off the sequence of message sizes that are recorded by the sensor.
Usage looks something like this:
// set up metrics: Metrics metrics = new Metrics(); // this is the global repository of metrics and sensors Sensor sensor = metrics.sensor("message-sizes"); sensor.add("kafka.producer.message-sizes.avg", new Avg()); sensor.add("kafka.producer.message-sizes.max", new Max()); // as messages are sent we record the sizes sensor.record(messageSize);
Constructor Summary | |
---|---|
Metrics()
Create a metrics repository with no metric reporters and default configuration. |
|
Metrics(MetricConfig defaultConfig)
Create a metrics repository with no reporters and the given default config. |
|
Metrics(MetricConfig defaultConfig,
java.util.List<MetricsReporter> reporters,
Time time)
Create a metrics repository with a default config and the given metric reporters |
|
Metrics(Time time)
Create a metrics repository with no metric reporters and default configuration. |
Method Summary | |
---|---|
void |
addMetric(java.lang.String name,
Measurable measurable)
Add a metric to monitor an object that implements measurable. |
void |
addMetric(java.lang.String name,
MetricConfig config,
Measurable measurable)
Add a metric to monitor an object that implements measurable. |
void |
addMetric(java.lang.String name,
java.lang.String description,
Measurable measurable)
Add a metric to monitor an object that implements measurable. |
void |
addMetric(java.lang.String name,
java.lang.String description,
MetricConfig config,
Measurable measurable)
Add a metric to monitor an object that implements measurable. |
void |
addReporter(MetricsReporter reporter)
Add a MetricReporter |
void |
close()
Close this metrics repository. |
Sensor |
getSensor(java.lang.String name)
Get the sensor with the given name if it exists |
java.util.Map<java.lang.String,KafkaMetric> |
metrics()
Get all the metrics currently maintained indexed by metric name |
Sensor |
sensor(java.lang.String name)
Get or create a sensor with the given unique name and no parent sensors. |
Sensor |
sensor(java.lang.String name,
MetricConfig config,
Sensor... parents)
Get or create a sensor with the given unique name and zero or more parent sensors. |
Sensor |
sensor(java.lang.String name,
Sensor... parents)
Get or create a sensor with the given unique name and zero or more parent sensors. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Metrics()
public Metrics(Time time)
public Metrics(MetricConfig defaultConfig)
defaultConfig
- The default config to use for all metrics that don't override their configpublic Metrics(MetricConfig defaultConfig, java.util.List<MetricsReporter> reporters, Time time)
defaultConfig
- The default configreporters
- The metrics reporterstime
- The time instance to use with the metricsMethod Detail |
---|
public Sensor getSensor(java.lang.String name)
name
- The name of the sensor
public Sensor sensor(java.lang.String name)
name
- The sensor name
public Sensor sensor(java.lang.String name, Sensor... parents)
name
- The name of the sensorparents
- The parent sensors
public Sensor sensor(java.lang.String name, MetricConfig config, Sensor... parents)
name
- The name of the sensorconfig
- A default configuration to use for this sensor for metrics that don't have their own configparents
- The parent sensors
public void addMetric(java.lang.String name, Measurable measurable)
name
- The name of the metricmeasurable
- The measurable that will be measured by this metricpublic void addMetric(java.lang.String name, java.lang.String description, Measurable measurable)
name
- The name of the metricdescription
- A human-readable description to include in the metricmeasurable
- The measurable that will be measured by this metricpublic void addMetric(java.lang.String name, MetricConfig config, Measurable measurable)
name
- The name of the metricconfig
- The configuration to use when measuring this measurablemeasurable
- The measurable that will be measured by this metricpublic void addMetric(java.lang.String name, java.lang.String description, MetricConfig config, Measurable measurable)
name
- The name of the metricdescription
- A human-readable description to include in the metricconfig
- The configuration to use when measuring this measurablemeasurable
- The measurable that will be measured by this metricpublic void addReporter(MetricsReporter reporter)
public java.util.Map<java.lang.String,KafkaMetric> metrics()
public void close()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |