Package com.yammer.metrics.core
Class BurstRateTrackingCounter
- java.lang.Object
-
- com.yammer.metrics.core.Counter
-
- com.yammer.metrics.core.BurstRateTrackingCounter
-
- All Implemented Interfaces:
com.yammer.metrics.core.Metric
public class BurstRateTrackingCounter extends com.yammer.metrics.core.Counter implements com.yammer.metrics.core.MetricA counter that accurately tracks burst rate, 1-minute rate and 5-minute rate, with customizable precision (defined bygranularityMillisparameter, which controls sample collection interval).- Author:
- vasily@wavefront.com
-
-
Constructor Summary
Constructors Constructor Description BurstRateTrackingCounter(com.yammer.metrics.core.MetricName metricName, com.yammer.metrics.core.MetricsRegistry metricsRegistry, int granularityMillis)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()longcount()voiddec()voiddec(long n)com.yammer.metrics.core.HistogramgetBurstRateHistogram()Get histogram of 1s burst rates.longgetCurrentRate()Get most recent 1-second rate.longgetFiveMinuteCount()Get delta value of the counter between now and 5 minutes ago.StringgetFiveMinutePrintableRate()Get 4-minute rate in human-readable form.DoublegetMaxBurstRateAndClear()Get highest burst rate and reset the histogram.longgetOneMinuteCount()Get delta value of the counter between now and 1 minute ago.StringgetOneMinutePrintableRate()Get 1-minute rate in human-readable form.static StringgetPrintableRate(long count)Convert a per minute count to human-readable per second rate.longgetSampleCount()Get the number of samples since the counter received its first non-zero sample.voidinc()voidinc(long n)<T> voidprocessWith(com.yammer.metrics.core.MetricProcessor<T> processor, com.yammer.metrics.core.MetricName name, T context)
-
-
-
Constructor Detail
-
BurstRateTrackingCounter
public BurstRateTrackingCounter(com.yammer.metrics.core.MetricName metricName, @Nullable com.yammer.metrics.core.MetricsRegistry metricsRegistry, int granularityMillis)- Parameters:
metricName- metric name for the counter.metricsRegistry- metrics registry for the counter. if null, default registry is used.granularityMillis- stats collection interval in milliseconds. lower granularity usually means better precision, but it always requires more memory (we need to track 5 minutes worth of data, so, for example, if granularity is set to 100ms, we have to keep 3000 long values).
-
-
Method Detail
-
getBurstRateHistogram
public com.yammer.metrics.core.Histogram getBurstRateHistogram()
Get histogram of 1s burst rates.- Returns:
- burst rate histogram
-
getCurrentRate
public long getCurrentRate()
Get most recent 1-second rate.- Returns:
- rate
-
getMaxBurstRateAndClear
public Double getMaxBurstRateAndClear()
Get highest burst rate and reset the histogram. .- Returns:
- burst rate
-
getOneMinutePrintableRate
public String getOneMinutePrintableRate()
Get 1-minute rate in human-readable form.- Returns:
- 1-minute rate as string
-
getFiveMinutePrintableRate
public String getFiveMinutePrintableRate()
Get 4-minute rate in human-readable form.- Returns:
- 4-minute rate as string
-
getOneMinuteCount
public long getOneMinuteCount()
Get delta value of the counter between now and 1 minute ago.- Returns:
- 1-minute delta value
-
getFiveMinuteCount
public long getFiveMinuteCount()
Get delta value of the counter between now and 5 minutes ago.- Returns:
- 5-minute delta value
-
getSampleCount
public long getSampleCount()
Get the number of samples since the counter received its first non-zero sample.- Returns:
- number of samples.
-
getPrintableRate
public static String getPrintableRate(long count)
Convert a per minute count to human-readable per second rate.- Parameters:
count- counter value.- Returns:
- human readable string
-
inc
public void inc()
- Overrides:
incin classcom.yammer.metrics.core.Counter
-
inc
public void inc(long n)
- Overrides:
incin classcom.yammer.metrics.core.Counter
-
dec
public void dec()
- Overrides:
decin classcom.yammer.metrics.core.Counter
-
dec
public void dec(long n)
- Overrides:
decin classcom.yammer.metrics.core.Counter
-
count
public long count()
- Overrides:
countin classcom.yammer.metrics.core.Counter
-
clear
public void clear()
- Overrides:
clearin classcom.yammer.metrics.core.Counter
-
processWith
public <T> void processWith(com.yammer.metrics.core.MetricProcessor<T> processor, com.yammer.metrics.core.MetricName name, T context) throws Exception- Specified by:
processWithin interfacecom.yammer.metrics.core.Metric- Overrides:
processWithin classcom.yammer.metrics.core.Counter- Throws:
Exception
-
-