Class ExponentiallyDecayingReservoir

java.lang.Object
io.dropwizard.metrics5.ExponentiallyDecayingReservoir
All Implemented Interfaces:
Reservoir

public class ExponentiallyDecayingReservoir extends Object implements Reservoir
An exponentially-decaying random reservoir of longs. Uses Cormode et al's forward-decaying priority reservoir sampling method to produce a statistically representative sampling reservoir, exponentially biased towards newer entries.
See Also:
  • Constructor Details

    • ExponentiallyDecayingReservoir

      public ExponentiallyDecayingReservoir()
      Creates a new ExponentiallyDecayingReservoir of 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.
    • ExponentiallyDecayingReservoir

      public ExponentiallyDecayingReservoir(int size, double alpha)
      Parameters:
      size - the number of samples to keep in the sampling reservoir
      alpha - the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer values
    • ExponentiallyDecayingReservoir

      public ExponentiallyDecayingReservoir(int size, double alpha, Clock clock)
      Parameters:
      size - the number of samples to keep in the sampling reservoir
      alpha - the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer values
      clock - the clock used to timestamp samples and track rescaling
  • Method Details

    • size

      public int size()
      Description copied from interface: Reservoir
      Returns the number of values recorded.
      Specified by:
      size in interface Reservoir
      Returns:
      the number of values recorded
    • update

      public void update(long value)
      Description copied from interface: Reservoir
      Adds a new recorded value to the reservoir.
      Specified by:
      update in interface Reservoir
      Parameters:
      value - a new recorded value
    • update

      public void update(long value, long timestamp)
      Adds an old value with a fixed timestamp to the reservoir.
      Parameters:
      value - the value to be added
      timestamp - the epoch timestamp of value in seconds
    • getSnapshot

      public Snapshot getSnapshot()
      Description copied from interface: Reservoir
      Returns a snapshot of the reservoir's values.
      Specified by:
      getSnapshot in interface Reservoir
      Returns:
      a snapshot of the reservoir's values