Class TimerImpl
- java.lang.Object
-
- fish.payara.microprofile.metrics.impl.TimerImpl
-
- All Implemented Interfaces:
org.eclipse.microprofile.metrics.Counting,org.eclipse.microprofile.metrics.Metered,org.eclipse.microprofile.metrics.Metric,org.eclipse.microprofile.metrics.Sampling,org.eclipse.microprofile.metrics.Timer
@Vetoed public class TimerImpl extends Object implements org.eclipse.microprofile.metrics.Timer
A timer metric which aggregates timing durations and provides duration statistics, plus throughput statistics viaMeter. The timer measures duration in nanoseconds.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()DurationgetElapsedTime()doublegetFifteenMinuteRate()doublegetFiveMinuteRate()doublegetMeanRate()doublegetOneMinuteRate()org.eclipse.microprofile.metrics.SnapshotgetSnapshot()org.eclipse.microprofile.metrics.Timer.Contexttime()Returns a newTimerImpl.Context.voidtime(Runnable event)Times and records the duration of event.<T> Ttime(Callable<T> event)Times and records the duration of event.StringtoString()voidupdate(long duration, TimeUnit unit)Adds a recorded duration.voidupdate(Duration 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)
- Specified by:
updatein interfaceorg.eclipse.microprofile.metrics.Timer
-
time
public <T> T time(Callable<T> event) throws Exception
Times and records the duration of event.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.Timer- 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
-
time
public void time(Runnable event)
Times and records the duration of event.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.Timer- Parameters:
event- aRunnablewhoseRunnable.run()method implements a process whose duration should be timed
-
time
public org.eclipse.microprofile.metrics.Timer.Context time()
Returns a newTimerImpl.Context.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.Timer- Returns:
- a new
TimerImpl.Context - See Also:
TimerImpl.Context
-
getElapsedTime
public Duration getElapsedTime()
- Specified by:
getElapsedTimein interfaceorg.eclipse.microprofile.metrics.Timer
-
getCount
public long getCount()
- Specified by:
getCountin interfaceorg.eclipse.microprofile.metrics.Counting- Specified by:
getCountin interfaceorg.eclipse.microprofile.metrics.Metered- Specified by:
getCountin interfaceorg.eclipse.microprofile.metrics.Timer
-
getFifteenMinuteRate
public double getFifteenMinuteRate()
- Specified by:
getFifteenMinuteRatein interfaceorg.eclipse.microprofile.metrics.Metered- Specified by:
getFifteenMinuteRatein interfaceorg.eclipse.microprofile.metrics.Timer
-
getFiveMinuteRate
public double getFiveMinuteRate()
- Specified by:
getFiveMinuteRatein interfaceorg.eclipse.microprofile.metrics.Metered- Specified by:
getFiveMinuteRatein interfaceorg.eclipse.microprofile.metrics.Timer
-
getMeanRate
public double getMeanRate()
- Specified by:
getMeanRatein interfaceorg.eclipse.microprofile.metrics.Metered- Specified by:
getMeanRatein interfaceorg.eclipse.microprofile.metrics.Timer
-
getOneMinuteRate
public double getOneMinuteRate()
- Specified by:
getOneMinuteRatein interfaceorg.eclipse.microprofile.metrics.Metered- Specified by:
getOneMinuteRatein interfaceorg.eclipse.microprofile.metrics.Timer
-
getSnapshot
public org.eclipse.microprofile.metrics.Snapshot getSnapshot()
- Specified by:
getSnapshotin interfaceorg.eclipse.microprofile.metrics.Sampling- Specified by:
getSnapshotin interfaceorg.eclipse.microprofile.metrics.Timer
-
-