Package io.dropwizard.metrics5
Class Timer
- java.lang.Object
-
- io.dropwizard.metrics5.Timer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimer.ContextA timing context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Returns the number of events which have been marked.doublegetFifteenMinuteRate()Returns the fifteen-minute moving average rate at which events have occurred since the meter was created.doublegetFiveMinuteRate()Returns the five-minute moving average rate at which events have occurred since the meter was created.doublegetMeanRate()Returns the mean rate at which events have occurred since the meter was created.doublegetOneMinuteRate()Returns the one-minute moving average rate at which events have occurred since the meter was created.SnapshotgetSnapshot()Returns a snapshot of the values.longgetSum()Returns the sum of events which have been marked.Timer.Contexttime()Returns a newTimer.Context.voidtime(Runnable event)Times and records the duration of event.<T> Ttime(Callable<T> event)Times and records the duration of event.<T> TtimeSupplier(Supplier<T> event)Times and records the duration of event.voidupdate(long duration, TimeUnit unit)Adds a recorded duration.voidupdate(Duration duration)Adds a recorded duration.
-
-
-
Method Detail
-
update
public void update(long duration, TimeUnit unit)Adds a recorded duration.- Parameters:
duration- the length of the durationunit- the scale unit ofduration
-
update
public void update(Duration duration)
Adds a recorded duration.- Parameters:
duration- theDurationto add to the timer. Negative or zero value are ignored.
-
time
public <T> T time(Callable<T> event) throws Exception
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
public <T> T timeSupplier(Supplier<T> event)
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
public void time(Runnable event)
Times and records the duration of event.- Parameters:
event- aRunnablewhoseRunnable.run()method implements a process whose duration should be timed
-
time
public Timer.Context time()
Returns a newTimer.Context.- Returns:
- a new
Timer.Context - See Also:
Timer.Context
-
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
public Snapshot getSnapshot()
Description copied from interface:SamplingReturns a snapshot of the values.- Specified by:
getSnapshotin interfaceSampling- Returns:
- a snapshot of the values
-
-