Class MaximumLatencyHistory

  • All Implemented Interfaces:
    ChainedEventObserver, ChainedObserver, SampledStatistic<java.lang.Long>, ValueStatistic<java.lang.Long>

    public class MaximumLatencyHistory
    extends java.lang.Object
    implements ChainedEventObserver, SampledStatistic<java.lang.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 Detail

      • latestAccumulator

        private final java.util.concurrent.atomic.AtomicReference<LatencyPeriodAccumulator> latestAccumulator
      • windowSizeNs

        private final long windowSizeNs
      • timeSupplier

        private final java.util.function.LongSupplier timeSupplier
      • drift

        private volatile long drift
    • Constructor Detail

      • MaximumLatencyHistory

        public MaximumLatencyHistory​(int historySize,
                                     long windowSize,
                                     java.util.concurrent.TimeUnit windowSizeUnit,
                                     java.util.function.LongSupplier timeSupplier)
      • MaximumLatencyHistory

        public MaximumLatencyHistory​(int historySize,
                                     long windowSize,
                                     java.util.concurrent.TimeUnit windowSizeUnit,
                                     java.util.function.LongSupplier timeSupplier,
                                     java.util.function.Consumer<LatencyPeriodAccumulator> sink)
        Parameters:
        historySize - The number of samples to keep
        windowSize - 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 unit
        sink - The sink used to collect the old values that are discarded from the history.
    • Method Detail

      • event

        public void event​(long timeNs,
                          long latencyNs)
        Description copied from interface: ChainedEventObserver
        Called to indicate an event happened.
        Specified by:
        event in interface ChainedEventObserver
        Parameters:
        timeNs - the clock at event completion in ns
        latencyNs - the event latency in ns
      • value

        public java.lang.Long value()
        Specified by:
        value in interface ValueStatistic<java.lang.Long>
        Returns:
        The current statistic value
      • history

        public java.util.List<Sample<java.lang.Long>> history()
        Description copied from interface: SampledStatistic
        The history of values
        Specified by:
        history in interface SampledStatistic<java.lang.Long>
        Returns:
        the list
      • history

        public java.util.List<Sample<java.lang.Long>> history​(long sinceMillis)
        Description copied from interface: SampledStatistic
        The history of values, since a given time in ms
        Specified by:
        history in interface SampledStatistic<java.lang.Long>
        Parameters:
        sinceMillis - starting point of history in ms
        Returns:
        the list