Interface ActionStatsCollector<E extends Enum<E>>
-
- Type Parameters:
E- The enum describing the different categories to be tracked
- All Superinterfaces:
JsonMonitorable
- All Known Implementing Classes:
AbstractActionStatsCollector,BlockingActionStatsCollector,NonBlockingActionStatsCollector
public interface ActionStatsCollector<E extends Enum<E>> extends JsonMonitorable
A common interface to all action statistics collectors. All collectors must be thread safe. However, they can choose to compromise data consistency for performance reasons.- Author:
- Eyal Schneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Clears all statistics.longduration()longend(E category)Indicates that an action has terminated.ActionStatsMap<E>getAll()longgetCompletedCount(E category)intgetRunning()longgetTotalDurationMicros(E category)voidstart()Indicates that an action has started.voidstartAndEnd(E category)Indicates the starting and termination of an "instant" action (duration = 0)-
Methods inherited from interface org.pipecraft.infra.monitoring.JsonMonitorable
getChildren, getFullMetrics, getOwnMetrics
-
-
-
-
Method Detail
-
start
void start()
Indicates that an action has started. Must be followed by end(category).
-
duration
long duration()
- Returns:
- The current duration (in microseconds) of the started action. Returns an undefined value if no action has been started yet.
-
end
long end(E category)
Indicates that an action has terminated.- Parameters:
category- The category to place the action stats into- Returns:
- The duration, in microseconds, of the action
-
startAndEnd
void startAndEnd(E category)
Indicates the starting and termination of an "instant" action (duration = 0)- Parameters:
category- The category to place the action stats into
-
getRunning
int getRunning()
- Returns:
- The number of actions currently in execution
-
getCompletedCount
long getCompletedCount(E category)
- Parameters:
category- A stats category- Returns:
- The number of actions of the given category that has been completed so far
-
getTotalDurationMicros
long getTotalDurationMicros(E category)
- Parameters:
category- A stats category- Returns:
- The total duration of completed actions in the given category
-
getAll
ActionStatsMap<E> getAll()
- Returns:
- A snapshot of all statistics. The data consistency guarantees depend on the specific implementation.
-
clear
void clear()
Clears all statistics. The atomicity of this operation depends on the specific implementation.
-
-