Class OperationsTracker

java.lang.Object
com.loomcache.server.metrics.OperationsTracker

public class OperationsTracker extends Object
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.

  • 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 type
      dataStructure - the data structure name
      latencyNs - the operation latency in nanoseconds
      success - whether the operation succeeded
    • getThroughput

      public double getThroughput(OperationsTracker.TimeWindow window)
      Get throughput for a time window in operations per second.
      Parameters:
      window - the time window
      Returns:
      operations per second
    • getLatencyPercentiles

      Get latency percentiles for a time window.
      Parameters:
      window - the time window
      Returns:
      latency percentiles in milliseconds
    • getErrorRate

      public double getErrorRate(OperationsTracker.TimeWindow window)
      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