Top Fields Constructors Methods
org.terracotta.statistics.derived.latency

public Class DefaultLatencyHistogramStatistic

extends Object
implements LatencyHistogramStatistic, ChainedEventObserver
Class Inheritance
All Implemented Interfaces
org.terracotta.statistics.observer.ChainedEventObserver, org.terracotta.statistics.observer.ChainedObserver, org.terracotta.statistics.derived.latency.LatencyHistogramStatistic, org.terracotta.statistics.derived.latency.LatencyHistogramQuery
Imports
org.terracotta.statistics.Time, org.terracotta.statistics.derived.histogram.BarSplittingBiasedHistogram, .Histogram, org.terracotta.statistics.observer.ChainedEventObserver, java.time.Duration, java.util.List, java.util.function.Function, .LongSupplier

Author
Mathieu Carbou

Field Summary

Modifier and TypeField and Description
private final BarSplittingBiasedHistogram
private long
private final long
private final LatencyHistogramQuery
private final LongSupplier

Constructor Summary

AccessConstructor and Description
public
DefaultLatencyHistogramStatistic(double
histogram bucket bias factor
phi
,
int
number of buckets
bucketCount
,
Duration
sliding window size, in ns
window
,
LongSupplier
the supplier of time, which must be in the same unit as the time passed to the {event(long, long)} method.
timeSupplier
)

Create a histogram maintained over a sliding time window.

public
DefaultLatencyHistogramStatistic(double phi, int bucketCount, Duration window)

Method Summary

Modifier and TypeMethod and Description
public List<Histogram.Bucket>
public long
public synchronized void
event(long
the clock at event completion in ns
time
,
long
the event latency in ns
latency
)

Implements org.terracotta.statistics.observer.ChainedEventObserver.event.

Called to indicate an event happened.
public Long
public Long
private static Long
nullOrVal(double val)

public Long
public long[]
public synchronized <T> T
query(Function<LatencyHistogramQuery, T> fn)

Implements org.terracotta.statistics.derived.latency.LatencyHistogramStatistic.query.

Enables to query the histogram several times within a synchronized state so that every calls are consistent
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
tryExpire(boolean force, LongSupplier time)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

histogramback to summary
private final BarSplittingBiasedHistogram histogram
nextPruningback to summary
private long nextPruning
pruningDelayback to summary
private final long pruningDelay
queryback to summary
private final LatencyHistogramQuery query
timeSupplierback to summary
private final LongSupplier timeSupplier

Constructor Detail

DefaultLatencyHistogramStatisticback to summary
public DefaultLatencyHistogramStatistic(double phi, int bucketCount, Duration window, LongSupplier timeSupplier)

Create a histogram maintained over a sliding time window.

The constructed histogram is:

  • maintained over window sliding window
  • consists of bucketCount buckets
  • where b1.size() ~= b0.size * phi
If "phi" is high, the quantile bounds will be more precise for lower percentiles such as minimum. If "phi" is low, the quantile bounds will be more precise for higher percentiles such as 99%-ile, maximum.
Parameters
phi:double

histogram bucket bias factor

bucketCount:int

number of buckets

window:Duration

sliding window size, in ns

timeSupplier:LongSupplier

the supplier of time, which must be in the same unit as the time passed to the {event(long, long)} method.

DefaultLatencyHistogramStatisticback to summary
public DefaultLatencyHistogramStatistic(double phi, int bucketCount, Duration window)

Method Detail

bucketsback to summary
public List<Histogram.Bucket> buckets()

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.buckets.

Annotations
@Override
countback to summary
public long count()

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.count.

Annotations
@Override
eventback to summary
public synchronized void event(long time, long latency)

Implements org.terracotta.statistics.observer.ChainedEventObserver.event.

Doc from org.terracotta.statistics.observer.ChainedEventObserver.event.

Called to indicate an event happened.

Parameters
time:long

the clock at event completion in ns

latency:long

the event latency in ns

Annotations
@Override
maximumback to summary
public Long maximum()

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.maximum.

Returns:Long

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.maximum.

The maximum value or null if no value

Annotations
@Override
minimumback to summary
public Long minimum()

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.minimum.

Returns:Long

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.minimum.

The minimum value or null if no value

Annotations
@Override
nullOrValback to summary
private static Long nullOrVal(double val)
percentileback to summary
public Long percentile(double percent)

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentile.

Parameters
percent:double

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentile.

the percentage (0.0-1.0)

Returns:Long

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentile.

the value below which percent% of the observations may be found. Will return the upper bound of the approximated range.

Annotations
@Override
percentileBoundsback to summary
public long[] percentileBounds(double percent)

Implements org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentileBounds.

Parameters
percent:double

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentileBounds.

the percentage (0.0-1.0)

Returns:long[]

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramQuery.percentileBounds.

the inclusive bounds (min and max) representing the range containing the right value for the given percent%-ile.

Annotations
@Override
queryback to summary
public synchronized <T> T query(Function<LatencyHistogramQuery, T> fn)

Implements org.terracotta.statistics.derived.latency.LatencyHistogramStatistic.query.

Doc from org.terracotta.statistics.derived.latency.LatencyHistogramStatistic.query.

Enables to query the histogram several times within a synchronized state so that every calls are consistent

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
tryExpireback to summary
private void tryExpire(boolean force, LongSupplier time)