org.apache.kafka.common.metrics
Class Sensor

java.lang.Object
  extended by org.apache.kafka.common.metrics.Sensor

public final class Sensor
extends java.lang.Object

A sensor applies a continuous sequence of numerical values to a set of associated metrics. For example a sensor on message size would record a sequence of message sizes using the record(double) api and would maintain a set of metrics about request sizes such as the average or max.


Method Summary
 void add(CompoundStat stat)
          Register a compound statistic with this sensor with no config override
 void add(CompoundStat stat, MetricConfig config)
          Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram)
 void add(java.lang.String name, MeasurableStat stat)
          Add a metric with default configuration and no description.
 void add(java.lang.String name, MeasurableStat stat, MetricConfig config)
          Add a metric to this sensor with no description.
 void add(java.lang.String name, java.lang.String description, MeasurableStat stat)
          Add a metric with default configuration.
 void add(java.lang.String name, java.lang.String description, MeasurableStat stat, MetricConfig config)
          Register a metric with this sensor
 java.lang.String name()
          The name this sensor is registered with.
 void record()
          Record an occurrence, this is just short-hand for record(1.0)
 void record(double value)
          Record a value with this sensor
 void record(double value, long timeMs)
          Record a value at a known time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

name

public java.lang.String name()
The name this sensor is registered with. This name will be unique among all registered sensors.


record

public void record()
Record an occurrence, this is just short-hand for record(1.0)


record

public void record(double value)
Record a value with this sensor

Parameters:
value - The value to record
Throws:
QuotaViolationException - if recording this value moves a metric beyond its configured maximum or minimum bound

record

public void record(double value,
                   long timeMs)
Record a value at a known time. This method is slightly faster than record(double) since it will reuse the time stamp.

Parameters:
value - The value we are recording
timeMs - The current POSIX time in milliseconds
Throws:
QuotaViolationException - if recording this value moves a metric beyond its configured maximum or minimum bound

add

public void add(CompoundStat stat)
Register a compound statistic with this sensor with no config override


add

public void add(CompoundStat stat,
                MetricConfig config)
Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram)

Parameters:
stat - The stat to register
config - The configuration for this stat. If null then the stat will use the default configuration for this sensor.

add

public void add(java.lang.String name,
                MeasurableStat stat)
Add a metric with default configuration and no description. Equivalent to add(name, "", stat, null)


add

public void add(java.lang.String name,
                java.lang.String description,
                MeasurableStat stat)
Add a metric with default configuration. Equivalent to add(name, description, stat, null)


add

public void add(java.lang.String name,
                MeasurableStat stat,
                MetricConfig config)
Add a metric to this sensor with no description. Equivalent to add(name, "", stat, config)

Parameters:
name -
stat -
config -

add

public void add(java.lang.String name,
                java.lang.String description,
                MeasurableStat stat,
                MetricConfig config)
Register a metric with this sensor

Parameters:
name - The name of the metric
description - A description used when reporting the value
stat - The statistic to keep
config - A special configuration for this metric. If null use the sensor default configuration.