Class SlidingTimeWindowReservoir

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

public class SlidingTimeWindowReservoir extends Object implements Reservoir
A Reservoir implementation backed by a sliding window that stores only the measurements made in the last N seconds (or other time unit).
  • Constructor Details

    • SlidingTimeWindowReservoir

      public SlidingTimeWindowReservoir(long window, TimeUnit windowUnit)
      Creates a new SlidingTimeWindowReservoir with the given window of time.
      Parameters:
      window - the window of time
      windowUnit - the unit of window
    • SlidingTimeWindowReservoir

      public SlidingTimeWindowReservoir(long window, TimeUnit windowUnit, Clock clock)
      Creates a new SlidingTimeWindowReservoir with the given clock and window of time.
      Parameters:
      window - the window of time
      windowUnit - the unit of window
      clock - the Clock to use
  • 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
    • 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