com.yammer.metrics.core
Class HistogramMetric

java.lang.Object
  extended by com.yammer.metrics.core.HistogramMetric
All Implemented Interfaces:
Metric, Percentiled, Summarized

public class HistogramMetric
extends Object
implements Metric, Percentiled, Summarized

A metric which calculates the distribution of a value.

See Also:
Accurately computing running variance

Nested Class Summary
static class HistogramMetric.SampleType
          The type of sampling the histogram should be performing.
 
Constructor Summary
HistogramMetric(HistogramMetric.SampleType type)
          Creates a new HistogramMetric with the given sample type.
HistogramMetric(Sample sample)
          Creates a new HistogramMetric with the given sample.
 
Method Summary
 void clear()
          Clears all recorded values.
 long count()
          Returns the number of values recorded.
 void dump(File output)
          Writes the values of the histogram's sample to the given file.
 double max()
          Returns the largest recorded value.
 double mean()
          Returns the arithmetic mean of all recorded values.
 double min()
          Returns the smallest recorded value.
 double percentile(double percentile)
          Returns the value at the given percentile.
 Double[] percentiles(Double... percentiles)
          Returns an array of values at the given percentiles.
<T> void
processWith(MetricsProcessor<T> processor, MetricName name, T context)
           
 double stdDev()
          Returns the standard deviation of all recorded values.
 void update(int value)
          Adds a recorded value.
 void update(long value)
          Adds a recorded value.
 List<Long> values()
          Returns a list of all values in the histogram's sample.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramMetric

public HistogramMetric(HistogramMetric.SampleType type)
Creates a new HistogramMetric with the given sample type.

Parameters:
type - the type of sample to use

HistogramMetric

public HistogramMetric(Sample sample)
Creates a new HistogramMetric with the given sample.

Parameters:
sample - the sample to create a histogram from
Method Detail

clear

public void clear()
Clears all recorded values.


update

public void update(int value)
Adds a recorded value.

Parameters:
value - the length of the value

update

public void update(long value)
Adds a recorded value.

Parameters:
value - the length of the value

count

public long count()
Returns the number of values recorded.

Returns:
the number of values recorded

max

public double max()
Description copied from interface: Summarized
Returns the largest recorded value.

Specified by:
max in interface Summarized
Returns:
the largest recorded value

min

public double min()
Description copied from interface: Summarized
Returns the smallest recorded value.

Specified by:
min in interface Summarized
Returns:
the smallest recorded value

mean

public double mean()
Description copied from interface: Summarized
Returns the arithmetic mean of all recorded values.

Specified by:
mean in interface Summarized
Returns:
the arithmetic mean of all recorded values

stdDev

public double stdDev()
Description copied from interface: Summarized
Returns the standard deviation of all recorded values.

Specified by:
stdDev in interface Summarized
Returns:
the standard deviation of all recorded values

percentile

public double percentile(double percentile)
Returns the value at the given percentile.

Specified by:
percentile in interface Percentiled
Parameters:
percentile - a percentile (0..1)
Returns:
the value at the given percentile

percentiles

public Double[] percentiles(Double... percentiles)
Returns an array of values at the given percentiles.

Specified by:
percentiles in interface Percentiled
Parameters:
percentiles - one or more percentiles (0..1)
Returns:
an array of values at the given percentiles

values

public List<Long> values()
Returns a list of all values in the histogram's sample.

Returns:
a list of all values in the histogram's sample

dump

public void dump(File output)
          throws IOException
Writes the values of the histogram's sample to the given file.

Parameters:
output - the file to which the values will be written
Throws:
IOException - if there is an error writing the values

processWith

public <T> void processWith(MetricsProcessor<T> processor,
                            MetricName name,
                            T context)
                 throws Exception
Specified by:
processWith in interface Metric
Throws:
Exception


Copyright © 2011. All Rights Reserved.