Package io.dropwizard.metrics5
Class Timer
java.lang.Object
io.dropwizard.metrics5.Timer
A timer metric which aggregates timing durations and provides duration statistics, plus
throughput statistics via
Meter.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetCount()Returns the number of events which have been marked.doubleReturns the fifteen-minute moving average rate at which events have occurred since the meter was created.doubleReturns the five-minute moving average rate at which events have occurred since the meter was created.doubleReturns the mean rate at which events have occurred since the meter was created.doubleReturns the one-minute moving average rate at which events have occurred since the meter was created.Returns a snapshot of the values.longgetSum()Returns the sum of events which have been marked.time()Returns a newTimer.Context.voidTimes and records the duration of event.<T> TTimes and records the duration of event.<T> TtimeSupplier(Supplier<T> event) Times and records the duration of event.voidAdds a recorded duration.voidAdds a recorded duration.
-
Constructor Details
-
Method Details
-
update
Adds a recorded duration.- Parameters:
duration- the length of the durationunit- the scale unit ofduration
-
update
Adds a recorded duration.- Parameters:
duration- theDurationto add to the timer. Negative or zero value are ignored.
-
time
Times and records the duration of event.- Type Parameters:
T- the type of the value returned byevent- Parameters:
event- aCallablewhoseCallable.call()method implements a process whose duration should be timed- Returns:
- the value returned by
event - Throws:
Exception- ifeventthrows anException
-
timeSupplier
Times and records the duration of event. Should not throw exceptions, for that use thetime(Callable)method.- Type Parameters:
T- the type of the value returned byevent- Parameters:
event- aSupplierwhoseSupplier.get()method implements a process whose duration should be timed- Returns:
- the value returned by
event
-
time
Times and records the duration of event.- Parameters:
event- aRunnablewhoseRunnable.run()method implements a process whose duration should be timed
-
time
Returns a newTimer.Context.- Returns:
- a new
Timer.Context - See Also:
-
getCount
public long getCount()Description copied from interface:MeteredReturns the number of events which have been marked. -
getSum
public long getSum()Description copied from interface:MeteredReturns the sum of events which have been marked. -
getFifteenMinuteRate
public double getFifteenMinuteRate()Description copied from interface:MeteredReturns the fifteen-minute moving average rate at which events have occurred since the meter was created.- Specified by:
getFifteenMinuteRatein interfaceMetered- Returns:
- the fifteen-minute moving average rate at which events have occurred since the meter was created
-
getFiveMinuteRate
public double getFiveMinuteRate()Description copied from interface:MeteredReturns the five-minute moving average rate at which events have occurred since the meter was created.- Specified by:
getFiveMinuteRatein interfaceMetered- Returns:
- the five-minute moving average rate at which events have occurred since the meter was created
-
getMeanRate
public double getMeanRate()Description copied from interface:MeteredReturns the mean rate at which events have occurred since the meter was created.- Specified by:
getMeanRatein interfaceMetered- Returns:
- the mean rate at which events have occurred since the meter was created
-
getOneMinuteRate
public double getOneMinuteRate()Description copied from interface:MeteredReturns the one-minute moving average rate at which events have occurred since the meter was created.- Specified by:
getOneMinuteRatein interfaceMetered- Returns:
- the one-minute moving average rate at which events have occurred since the meter was created
-
getSnapshot
Description copied from interface:SamplingReturns a snapshot of the values.- Specified by:
getSnapshotin interfaceSampling- Returns:
- a snapshot of the values
-