public interface TimedMetric extends Metric
| Modifier and Type | Method and Description |
|---|---|
void |
addEventDuration(boolean success,
long durationNanos)
Add an event duration in nanoseconds noting if it was a success or failure result.
|
void |
addEventSince(boolean success,
long startNanos)
Add an event based on a startNanos (determined by
System.nanoTime()). |
Map<String,String> |
attributes()
Return extra attributes that can be included in the request logging.
|
void |
decrementCollectionCount()
Decrement the request timing collection count.
|
String |
getBucketRange()
Return the bucket range or empty string if not a bucket.
|
int |
getRequestTimingCollection()
Return the number of remaining requests to collect detailed timing on.
|
boolean |
isActiveThreadContext()
Return true if this TimedMetric has been pushed onto an active context for this thread.
|
boolean |
isBucket()
Return true if this timed metric is part of a bucket range (and hence only hold statistics for the
bucket range returned by
bucketRange(). |
void |
operationEnd(int opCode,
long startNanos)
Add an event duration with opCode indicating success or failure.
|
void |
operationEnd(int opCode,
long startNanos,
boolean activeThreadContext)
Add an event duration with opCode indicating success or failure.
|
void |
setRequestTimingCollection(int collectionCount)
Specify to collect per request detailed timing collection.
|
TimedEvent |
startEvent()
Start an event.
|
TimedEvent startEvent()
At the completion of the event one of TimedEvent.endWithSuccess(),
TimedEvent.endWithError() or TimedEvent.end(boolean) is called to record the
event duration and success or otherwise.
This is an alternative to using addEventSince(boolean, long) or
addEventDuration(boolean, long). Note that this startEvent() method has slightly
higher overhead as it instantiates a TimedEvent object which must be later GC'ed. In this sense
generally addEventSince() is the preferred method to use.
void addEventSince(boolean success, long startNanos)
System.nanoTime()).
Success and failure statistics are kept separately.
This is an alternative to using startEvent(). Note that using startEvent() has
slightly higher overhead as it instantiates a TimedEvent object which must be later GC'ed. In
this sense generally addEventSince() is the preferred method to use.
void addEventDuration(boolean success, long durationNanos)
Success and failure statistics are kept separately.
This is an alternative to using addEventSince(boolean, long) where you pass in the
duration rather than the start nanoseconds.
boolean isBucket()
bucketRange().String getBucketRange()
void operationEnd(int opCode, long startNanos, boolean activeThreadContext)
Although this looks redundant and a little ugly having this method means that for enhancement the added byte code is minimised. In the case where metric collection is turned off overhead is limited to a System.nanoTime() call and a noop method call.
void operationEnd(int opCode, long startNanos)
boolean isActiveThreadContext()
This means that the current thread is actively collecting timing entries and this metric has been pushed onto the nested context.
void setRequestTimingCollection(int collectionCount)
This is expected to only be explicitly called on 'top level' metrics such as web endpoints. Once a request timing context has been created by the top level metric then 'nested metrics' (typically service and data access layers) can append to that existing context. In this way detailed per request level timing entries can be collected for only selected endpoints.
int getRequestTimingCollection()
This value starts out as the value set by #setRequestTimingCollection and then decrements after a request timing is reported until it reaches 0 at which point request timing automatically turns off for this metric.
void decrementCollectionCount()
This is typically called internally when a request timing is reported and generally not expected to be called by application code.
Map<String,String> attributes()
Copyright © 2019. All rights reserved.