Package org.rapidcontext.core.data.stat
Class MovingUsage
java.lang.Object
org.rapidcontext.core.data.stat.MovingUsage
A combined usage metric with moving counters, average durations
and recent errors.
- Version:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionMovingUsage
(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 TypeMethodDescriptionvoid
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
time()
Returns the timestamp (in millis) for the most recent move.values()
Returns a dictionary with the current counters and other metrics.
-
Constructor Details
-
MovingUsage
public MovingUsage(long now) Initializes a new set of moving usage metrics.- Parameters:
now
- the current time (in millis)
-
MovingUsage
Initializes a set of moving usage metrics from serialized data.- Parameters:
now
- the current time (in millis)dict
- the serialized dictionary
-
-
Method Details
-
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
Returns a dictionary with the current counters and other metrics.- Returns:
- a dictionary with metric values
-
add
Increases the usage counters and average durations.- Parameters:
value
- the usage count to add, or zero (0) for noneduration
- the duration (in millis), or zero (0) to skipsuccess
- the success flagerror
- 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)
-