Top Description Inners Methods
org.eclipse.microprofile.metrics

public Interface Timer

extends Metric, Sampling
Imports
java.io.Closeable, java.time.Duration, java.util.concurrent.Callable

A timer metric which aggregates timing durations and provides duration statistics

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Timer.Context

A timing context.

Method Summary

Modifier and TypeMethod and Description
public long
public Duration

Returns:

the elapsed time duration
getElapsedTime
()

Returns the total elapsed timing durations of all completed timing events that are recorded with update(Duration).

public Snapshot
getSnapshot()

Redeclares org.eclipse.microprofile.metrics.Sampling.getSnapshot.

Returns a snapshot of the values.

public <
the type of the value returned by event
T
>
T

Returns:

the value returned by event
time
(Callable<T>
a Callable whose Callable#call() method implements a process whose duration should be timed
event
)

Times and records the duration of event.

public void
time(Runnable
a Runnable whose Runnable#run() method implements a process whose duration should be timed
event
)

Times and records the duration of event.

public Timer.Context

Returns:

a new Context
time
()

Returns a new Context.

public void
update(Duration
the length of the duration
duration
)

Adds a recorded duration.

Method Detail

getCountback to summary
public long getCount()
getElapsedTimeback to summary
public Duration getElapsedTime()

Returns the total elapsed timing durations of all completed timing events that are recorded with update(Duration).

Returns:Duration

the elapsed time duration

getSnapshotback to summary
public Snapshot getSnapshot()

Redeclares org.eclipse.microprofile.metrics.Sampling.getSnapshot.

Doc from org.eclipse.microprofile.metrics.Sampling.getSnapshot.

Returns a snapshot of the values.

Returns:Snapshot

a snapshot of the values

Annotations
@Override
timeback to summary
public <T> T time(Callable<T> event) throws Exception

Times and records the duration of event.

Parameters
<T>
the type of the value returned by event
event:Callable<T>

a Callable whose Callable#call() method implements a process whose duration should be timed

Returns:T

the value returned by event

Exceptions
Exception:
if event throws an Exception
timeback to summary
public void time(Runnable event)

Times and records the duration of event.

Parameters
event:Runnable

a Runnable whose Runnable#run() method implements a process whose duration should be timed

timeback to summary
public Timer.Context time()

Returns a new Context.

Returns:Timer.Context

a new Context

See Also
Context
updateback to summary
public void update(Duration duration)

Adds a recorded duration.

Parameters
duration:Duration

the length of the duration

org.eclipse.microprofile.metrics back to summary

public Interface Timer.Context

extends Closeable

A timing context.
See Also
Timer#time()

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.io.Closeable.close.

Equivalent to calling stop().

public long

Returns:

the elapsed time in nanoseconds
stop
()

Updates the timer with the difference between current and start time.

Method Detail

closeback to summary
public void close()

Redeclares java.io.Closeable.close.

Equivalent to calling stop().

Annotations
@Override
stopback to summary
public long stop()

Updates the timer with the difference between current and start time. Call to this method will not reset the start time. Multiple calls result in multiple updates.

Returns:long

the elapsed time in nanoseconds