Class LatencyRecordingHandler

All Implemented Interfaces:
Handler, Handler.Container, Handler.Singleton, Request.Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable

public abstract class LatencyRecordingHandler extends EventsHandler

A Handler that helps recording the total latency of the requests executed by the wrapped handler.

The latency reported by onRequestComplete(String, long) is the delay between when the request arrived to a connector until the completion of that request.

  • Constructor Details

    • LatencyRecordingHandler

      public LatencyRecordingHandler()
    • LatencyRecordingHandler

      public LatencyRecordingHandler(Handler handler)
  • Method Details

    • onComplete

      protected final void onComplete(Request request, int status, HttpFields headers, Throwable failure)
      Description copied from class: EventsHandler
      Invoked when the request and response processing are complete, just before the request and response will be recycled (i.e. after the Runnable return from HttpChannel.onRequest(MetaData.Request) has returned and the Callback passed to Request.Handler.handle(Request, Response, Callback) has been completed).
      Overrides:
      onComplete in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      status - the response status.
      headers - the immutable fields of the response object.
      failure - if there was a failure to complete.
    • onRequestComplete

      protected abstract void onRequestComplete(String requestId, long durationInNs)
      Called back for each completed request with its execution's latency.
      Parameters:
      requestId - the ID of the request
      durationInNs - the duration in nanoseconds of the completed request