Class MovingUsage

java.lang.Object
org.rapidcontext.core.data.stat.MovingUsage

public class MovingUsage extends Object
A combined usage metric with moving counters, average durations and recent errors.
Version:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    MovingUsage(long now)
    Initializes a new set of moving usage metrics.
    MovingUsage(long now, Dict dict)
    Initializes a set of moving usage metrics from serialized data.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int value, long duration, boolean success, String error)
    Increases the usage counters and average durations.
    void
    move(long now)
    Move the current time and possibly roll-over one or more of the moving sums.
    Returns a dictionary with the serialized metric values.
    long
    Returns the timestamp (in millis) for the most recent move.
    Returns a dictionary with the current counters and other metrics.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MovingUsage

      public MovingUsage(long now)
      Initializes a new set of moving usage metrics.
      Parameters:
      now - the current time (in millis)
    • MovingUsage

      public MovingUsage(long now, Dict dict)
      Initializes a set of moving usage metrics from serialized data.
      Parameters:
      now - the current time (in millis)
      dict - the serialized dictionary
  • Method Details

    • serialize

      public Dict serialize()
      Returns a dictionary with the serialized metric values.
      Returns:
      a dictionary with serialized values
    • time

      public long time()
      Returns the timestamp (in millis) for the most recent move.
      Returns:
      the current interval timestamp (in millis)
    • values

      public Dict values()
      Returns a dictionary with the current counters and other metrics.
      Returns:
      a dictionary with metric values
    • add

      public void add(int value, long duration, boolean success, String error)
      Increases the usage counters and average durations.
      Parameters:
      value - the usage count to add, or zero (0) for none
      duration - the duration (in millis), or zero (0) to skip
      success - the success flag
      error - the optional error message
    • move

      public void move(long now)
      Move the current time and possibly roll-over one or more of the moving sums.
      Parameters:
      now - the current time (in millis)