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 long
getCount()
Duration
getElapsedTime()
double
getFifteenMinuteRate()
double
getFiveMinuteRate()
double
getMeanRate()
double
getOneMinuteRate()
org.eclipse.microprofile.metrics.Snapshot
getSnapshot()
org.eclipse.microprofile.metrics.Timer.Context
time()
Returns a newTimerImpl.Context
.void
time(Runnable event)
Times and records the duration of event.<T> T
time(Callable<T> event)
Times and records the duration of event.String
toString()
void
update(long duration, TimeUnit unit)
Adds a recorded duration.void
update(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:
update
in interfaceorg.eclipse.microprofile.metrics.Timer
-
time
public <T> T time(Callable<T> event) throws Exception
Times and records the duration of event.- Specified by:
time
in interfaceorg.eclipse.microprofile.metrics.Timer
- Type Parameters:
T
- the type of the value returned byevent
- Parameters:
event
- aCallable
whoseCallable.call()
method implements a process whose duration should be timed- Returns:
- the value returned by
event
- Throws:
Exception
- ifevent
throws anException
-
time
public void time(Runnable event)
Times and records the duration of event.- Specified by:
time
in interfaceorg.eclipse.microprofile.metrics.Timer
- Parameters:
event
- aRunnable
whoseRunnable.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:
time
in interfaceorg.eclipse.microprofile.metrics.Timer
- Returns:
- a new
TimerImpl.Context
- See Also:
TimerImpl.Context
-
getElapsedTime
public Duration getElapsedTime()
- Specified by:
getElapsedTime
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getCount
public long getCount()
- Specified by:
getCount
in interfaceorg.eclipse.microprofile.metrics.Counting
- Specified by:
getCount
in interfaceorg.eclipse.microprofile.metrics.Metered
- Specified by:
getCount
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getFifteenMinuteRate
public double getFifteenMinuteRate()
- Specified by:
getFifteenMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Metered
- Specified by:
getFifteenMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getFiveMinuteRate
public double getFiveMinuteRate()
- Specified by:
getFiveMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Metered
- Specified by:
getFiveMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getMeanRate
public double getMeanRate()
- Specified by:
getMeanRate
in interfaceorg.eclipse.microprofile.metrics.Metered
- Specified by:
getMeanRate
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getOneMinuteRate
public double getOneMinuteRate()
- Specified by:
getOneMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Metered
- Specified by:
getOneMinuteRate
in interfaceorg.eclipse.microprofile.metrics.Timer
-
getSnapshot
public org.eclipse.microprofile.metrics.Snapshot getSnapshot()
- Specified by:
getSnapshot
in interfaceorg.eclipse.microprofile.metrics.Sampling
- Specified by:
getSnapshot
in interfaceorg.eclipse.microprofile.metrics.Timer
-
-