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:

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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enumeration of the main failure classes.
  • 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, RequestTracker.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, RequestTracker.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.