Class OperationsTracker
java.lang.Object
com.loomcache.server.metrics.OperationsTracker
Tracks all cache operations with type, latency, and success/failure status.
Maintains sliding window counters for throughput and latency percentile calculation.
Thread-safe using ReentrantReadWriteLock.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordLatency percentiles record.static final recordOperation record.static enumOperation types.static enumSliding window time ranges. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all recorded operations.doubleGet error rate for a time window (0.0 to 1.0).Get latency percentiles for a time window.intGet total number of recorded operations.Get operation count by type for a time window.Get all operations within a time window.doubleGet throughput for a time window in operations per second.voidrecordOperation(OperationsTracker.OperationType type, String dataStructure, long latencyNs, boolean success) Record an operation.
-
Constructor Details
-
OperationsTracker
public OperationsTracker()Create a new OperationsTracker.
-
-
Method Details
-
recordOperation
public void recordOperation(OperationsTracker.OperationType type, String dataStructure, long latencyNs, boolean success) Record an operation.- Parameters:
type- the operation typedataStructure- the data structure namelatencyNs- the operation latency in nanosecondssuccess- whether the operation succeeded
-
getThroughput
Get throughput for a time window in operations per second.- Parameters:
window- the time window- Returns:
- operations per second
-
getLatencyPercentiles
public OperationsTracker.LatencyPercentiles getLatencyPercentiles(OperationsTracker.TimeWindow window) Get latency percentiles for a time window.- Parameters:
window- the time window- Returns:
- latency percentiles in milliseconds
-
getErrorRate
Get error rate for a time window (0.0 to 1.0).- Parameters:
window- the time window- Returns:
- error rate
-
getOperationCountsByType
public Map<OperationsTracker.OperationType, Long> getOperationCountsByType(OperationsTracker.TimeWindow window) Get operation count by type for a time window.- Parameters:
window- the time window- Returns:
- map of operation type to count
-
clear
public void clear()Clear all recorded operations. -
getOperationCount
public int getOperationCount()Get total number of recorded operations.- Returns:
- operation count
-
getOperations
Get all operations within a time window.- Parameters:
window- the time window- Returns:
- list of operations
-