org.apache.kafka.common.metrics.stats
Class Rate

java.lang.Object
  extended by org.apache.kafka.common.metrics.stats.Rate
All Implemented Interfaces:
Measurable, MeasurableStat, Stat

public class Rate
extends java.lang.Object
implements MeasurableStat

The rate of the given quantity. By default this is the total observed over a set of samples from a sampled statistic divided by the elapsed time over the sample windows. Alternative SampledStat implementations can be provided, however, to record the rate of occurrences (e.g. the count of values measured over the time interval) or other such values.


Nested Class Summary
static class Rate.SampledTotal
           
 
Constructor Summary
Rate()
           
Rate(SampledStat stat)
           
Rate(java.util.concurrent.TimeUnit unit)
           
Rate(java.util.concurrent.TimeUnit unit, SampledStat stat)
           
 
Method Summary
 double measure(MetricConfig config, long now)
          Measure this quantity and return the result as a double
 void record(MetricConfig config, double value, long timeMs)
          Record the given value
 java.lang.String unitName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rate

public Rate()

Rate

public Rate(java.util.concurrent.TimeUnit unit)

Rate

public Rate(SampledStat stat)

Rate

public Rate(java.util.concurrent.TimeUnit unit,
            SampledStat stat)
Method Detail

unitName

public java.lang.String unitName()

record

public void record(MetricConfig config,
                   double value,
                   long timeMs)
Description copied from interface: Stat
Record the given value

Specified by:
record in interface Stat
Parameters:
config - The configuration to use for this metric
value - The value to record
timeMs - The POSIX time in milliseconds this value occurred

measure

public double measure(MetricConfig config,
                      long now)
Description copied from interface: Measurable
Measure this quantity and return the result as a double

Specified by:
measure in interface Measurable
Parameters:
config - The configuration for this metric
now - The POSIX time in milliseconds the measurement is being taken
Returns:
The measured value