Class PackedAggregation

java.lang.Object
io.github.resilience4j.core.metrics.PackedAggregation
All Implemented Interfaces:
CumulativeMeasurement, MeasurementData

public class PackedAggregation extends Object implements CumulativeMeasurement
A measurement implementation used in sliding windows to track the total duration and the number of calls in the window, along with the duration and number of calls of the current entry/bucket.

This implementation has the advantage of being cache friendly, benefiting from cache locality when counting/discarding the tracked metrics.

Besides this, metrics can also be quickly cloned, which is important for the lock-free algorithms which are operating with immutable objects.

  • Constructor Details

    • PackedAggregation

      public PackedAggregation()
    • PackedAggregation

      public PackedAggregation(long[] durations, int[] counts)
  • Method Details

    • record

      public void record(long duration, TimeUnit durationUnit, Metrics.Outcome outcome)
      Description copied from interface: CumulativeMeasurement
      Records a call duration and its outcome.
      Specified by:
      record in interface CumulativeMeasurement
      Parameters:
      duration - the call duration
      durationUnit - the time unit of the call duration
      outcome - the outcome of the call
    • getTotalDurationInMillis

      public long getTotalDurationInMillis()
      Description copied from interface: MeasurementData
      Returns the total duration of all calls in this measurement.
      Specified by:
      getTotalDurationInMillis in interface MeasurementData
      Returns:
      the total duration of all calls
    • getNumberOfSlowCalls

      public int getNumberOfSlowCalls()
      Description copied from interface: MeasurementData
      Returns the number of calls in this measurement which were slower than a certain threshold.
      Specified by:
      getNumberOfSlowCalls in interface MeasurementData
      Returns:
      the number of calls which were slower than a certain threshold
    • getNumberOfSlowFailedCalls

      public int getNumberOfSlowFailedCalls()
      Description copied from interface: MeasurementData
      Returns the number of failed calls in this measurement which were slower than a certain threshold.
      Specified by:
      getNumberOfSlowFailedCalls in interface MeasurementData
      Returns:
      the number of failed calls which were slower than a certain threshold
    • getNumberOfFailedCalls

      public int getNumberOfFailedCalls()
      Description copied from interface: MeasurementData
      Returns the number of failed calls in this measurement.
      Specified by:
      getNumberOfFailedCalls in interface MeasurementData
      Returns:
      the number of failed calls
    • getNumberOfCalls

      public int getNumberOfCalls()
      Description copied from interface: MeasurementData
      Returns the total number of all calls in this measurement.
      Specified by:
      getNumberOfCalls in interface MeasurementData
      Returns:
      the total number of all calls
    • toString

      public String toString()
      Overrides:
      toString in class Object