Class DefaultLatencyHistogramStatistic
- java.lang.Object
-
- org.terracotta.statistics.derived.latency.DefaultLatencyHistogramStatistic
-
- All Implemented Interfaces:
LatencyHistogramQuery,LatencyHistogramStatistic,ChainedEventObserver,ChainedObserver
public class DefaultLatencyHistogramStatistic extends java.lang.Object implements LatencyHistogramStatistic, ChainedEventObserver
-
-
Field Summary
Fields Modifier and Type Field Description private BarSplittingBiasedHistogramhistogramprivate longnextPruningprivate longpruningDelayprivate LatencyHistogramQueryqueryprivate java.util.function.LongSuppliertimeSupplier
-
Constructor Summary
Constructors Constructor Description DefaultLatencyHistogramStatistic(double phi, int bucketCount, java.time.Duration window)DefaultLatencyHistogramStatistic(double phi, int bucketCount, java.time.Duration window, java.util.function.LongSupplier timeSupplier)Create a histogram maintained over a sliding time window.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Histogram.Bucket>buckets()longcount()voidevent(long time, long latency)Called to indicate an event happened.java.lang.Longmaximum()java.lang.Longminimum()private static java.lang.LongnullOrVal(double val)java.lang.Longpercentile(double percent)long[]percentileBounds(double percent)<T> Tquery(java.util.function.Function<LatencyHistogramQuery,T> fn)Enables to query the histogram several times within a synchronized state so that every calls are consistentjava.lang.StringtoString()private voidtryExpire(boolean force, java.util.function.LongSupplier time)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.terracotta.statistics.derived.latency.LatencyHistogramQuery
median
-
Methods inherited from interface org.terracotta.statistics.derived.latency.LatencyHistogramStatistic
maximumStatistic, medianStatistic, minimumStatistic, percentileStatistic
-
-
-
-
Field Detail
-
histogram
private final BarSplittingBiasedHistogram histogram
-
timeSupplier
private final java.util.function.LongSupplier timeSupplier
-
pruningDelay
private final long pruningDelay
-
query
private final LatencyHistogramQuery query
-
nextPruning
private long nextPruning
-
-
Constructor Detail
-
DefaultLatencyHistogramStatistic
public DefaultLatencyHistogramStatistic(double phi, int bucketCount, java.time.Duration window, java.util.function.LongSupplier timeSupplier)Create a histogram maintained over a sliding time window.The constructed histogram is:
- maintained over
windowsliding window - consists of
bucketCountbuckets - where
b1.size() ~= b0.size * phi
- Parameters:
phi- histogram bucket bias factorbucketCount- number of bucketswindow- sliding window size, in nstimeSupplier- the supplier of time, which must be in the same unit as the time passed to the {event(long, long)} method.
- maintained over
-
DefaultLatencyHistogramStatistic
public DefaultLatencyHistogramStatistic(double phi, int bucketCount, java.time.Duration window)
-
-
Method Detail
-
buckets
public java.util.List<Histogram.Bucket> buckets()
- Specified by:
bucketsin interfaceLatencyHistogramQuery
-
count
public long count()
- Specified by:
countin interfaceLatencyHistogramQuery
-
minimum
public java.lang.Long minimum()
- Specified by:
minimumin interfaceLatencyHistogramQuery- Returns:
- The minimum value or null if no value
-
maximum
public java.lang.Long maximum()
- Specified by:
maximumin interfaceLatencyHistogramQuery- Returns:
- The maximum value or null if no value
-
percentile
public java.lang.Long percentile(double percent)
- Specified by:
percentilein interfaceLatencyHistogramQuery- Parameters:
percent- the percentage (0.0-1.0)- Returns:
- the value below which percent% of the observations may be found. Will return the upper bound of the approximated range.
-
percentileBounds
public long[] percentileBounds(double percent)
- Specified by:
percentileBoundsin interfaceLatencyHistogramQuery- Parameters:
percent- the percentage (0.0-1.0)- Returns:
- the inclusive bounds (min and max) representing the range containing the right value for the given percent%-ile.
-
event
public void event(long time, long latency)Description copied from interface:ChainedEventObserverCalled to indicate an event happened.- Specified by:
eventin interfaceChainedEventObserver- Parameters:
time- the clock at event completion in nslatency- the event latency in ns
-
query
public <T> T query(java.util.function.Function<LatencyHistogramQuery,T> fn)
Description copied from interface:LatencyHistogramStatisticEnables to query the histogram several times within a synchronized state so that every calls are consistent- Specified by:
queryin interfaceLatencyHistogramStatistic
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
tryExpire
private void tryExpire(boolean force, java.util.function.LongSupplier time)
-
nullOrVal
private static java.lang.Long nullOrVal(double val)
-
-