Class MaximumLatencyHistory
java.lang.Object
org.terracotta.statistics.derived.latency.MaximumLatencyHistory
- All Implemented Interfaces:
ChainedEventObserver,ChainedObserver,SampledStatistic<Long>,ValueStatistic<Long>
public class MaximumLatencyHistory
extends Object
implements ChainedEventObserver, SampledStatistic<Long>
Keeps a history of the maximum operation latencies over a specific window.
The window needs to be as small as possible to get the most detailed history.
This is important to note that the history is based on a sample count and not a time frame. If you set a history to 100 samples and a window of 500ms, you won't have a complete time-frame of 10 seconds. You can have a sample at t0, then another one at t0 + 1 sec depending on when the operations occur.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Queue<LatencyPeriodAccumulator>private longprivate final AtomicReference<LatencyPeriodAccumulator>private final Consumer<LatencyPeriodAccumulator>private final LongSupplierprivate final long -
Constructor Summary
ConstructorsConstructorDescriptionMaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier) MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier, Consumer<LatencyPeriodAccumulator> sink) -
Method Summary
-
Field Details
-
latestAccumulator
-
archive
-
windowSizeNs
private final long windowSizeNs -
sink
-
timeSupplier
-
drift
private volatile long drift
-
-
Constructor Details
-
MaximumLatencyHistory
public MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier) -
MaximumLatencyHistory
public MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier, Consumer<LatencyPeriodAccumulator> sink) - Parameters:
historySize- The number of samples to keepwindowSize- The size of the window over which the reduction is applied. A small value is better for more details, but history might discard values faster.windowSizeUnit- Window size unitsink- The sink used to collect the old values that are discarded from the history.
-
-
Method Details
-
event
public void event(long timeNs, long latencyNs) Description copied from interface:ChainedEventObserverCalled to indicate an event happened.- Specified by:
eventin interfaceChainedEventObserver- Parameters:
timeNs- the clock at event completion in nslatencyNs- the event latency in ns
-
value
- Specified by:
valuein interfaceValueStatistic<Long>- Returns:
- The current statistic value
-
type
- Specified by:
typein interfaceValueStatistic<Long>- Returns:
- The statistic type
-
history
Description copied from interface:SampledStatisticThe history of values- Specified by:
historyin interfaceSampledStatistic<Long>- Returns:
- the list
-
history
Description copied from interface:SampledStatisticThe history of values, since a given time in ms- Specified by:
historyin interfaceSampledStatistic<Long>- Parameters:
sinceMillis- starting point of history in ms- Returns:
- the list
-
insert
-