Interface RequestTracker


public interface RequestTracker
A tracker of latency of an action over time.

The usage of the RequestTracker is intended to follow the simple workflow: - At initiation of an action for which a request is must call beforeRequestStart() and save the timestamp much like would be done when using a stamped lock. - Once the request event is complete only one of the onRequestSuccess(long) or onRequestError(long, ErrorClass) methods must be called and called exactly once. In other words, every call to beforeRequestStart() must be followed by exactly one call to either of the completion methods onRequestSuccess(long) or onRequestError(long, ErrorClass). Failure to do so can cause state corruption in the RequestTracker implementations which may track not just latency but also the outstanding requests.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Invoked before each start of the action for which latency is to be tracked.
    void
    onRequestError(long beforeStartTimeNs, ErrorClass errorClass)
    Records a failed completion of the action for which latency is to be tracked.
    void
    onRequestSuccess(long beforeStartTimeNs)
    Records a successful completion of the action for which latency is to be tracked.
  • Field Details

  • Method Details

    • beforeRequestStart

      long beforeRequestStart()
      Invoked before each start of the action for which latency is to be tracked.
      Returns:
      Current time in nanoseconds.
    • onRequestSuccess

      void onRequestSuccess(long beforeStartTimeNs)
      Records a successful completion of the action for which latency is to be tracked.
      Parameters:
      beforeStartTimeNs - return value from beforeRequestStart().
    • onRequestError

      void onRequestError(long beforeStartTimeNs, ErrorClass errorClass)
      Records a failed completion of the action for which latency is to be tracked.
      Parameters:
      beforeStartTimeNs - return value from beforeRequestStart().
      errorClass - the class of error that triggered this method.