Package io.servicetalk.client.api
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 that will be tracked the caller 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)
oronRequestError(long, ErrorClass)
methods must be called and called exactly once
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 ClassesModifier and TypeInterfaceDescriptionstatic enum
Enumeration of the main failure classes. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlong
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
-
REQUEST_TRACKER_KEY
-
-
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 frombeforeRequestStart()
.
-
onRequestError
Records a failed completion of the action for which latency is to be tracked.- Parameters:
beforeStartTimeNs
- return value frombeforeRequestStart()
.errorClass
- the class of error that triggered this method.
-