Package org.eclipse.microprofile.metrics

## Interface Timer

All Superinterfaces:
  `Metric`, `Sampling`

    public interface Timer
    extends Metric, Sampling

A timer metric which aggregates timing durations and provides duration statistics

### Nested Class Summary

Nested Classes
`static interface` `Timer.Context` A timing context.

### Method Summary

All Methods Instance Methods Abstract Methods
`long` `getCount()`
`Duration` `getElapsedTime()` Returns the total elapsed timing durations of all completed timing events that are recorded with `update(Duration)`.
`Snapshot` `getSnapshot()` Returns a snapshot of the values.
`Timer.Context` `time()` Returns a new `Timer.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.
`void` `update​(Duration duration)` Adds a recorded duration.

### Method Detail

#### update

    void update​(Duration duration)

Adds a recorded duration.

Parameters:
  `duration` - the length of the `duration`

#### time

    <T> T time​(Callable<T> event)
        throws Exception

Times and records the duration of event.

Type Parameters:
  `T` - the type of the value returned by `event`
Parameters:
  `event` - a `Callable` whose `Callable.call()` method implements a process whose duration should be timed
Returns:
  the value returned by `event`
Throws:
  `Exception` - if `event` throws an `Exception`

#### time

    void time​(Runnable event)

Times and records the duration of event.

Parameters:
  `event` - a `Runnable` whose `Runnable.run()` method implements a process whose duration should be timed

#### time

    Timer.Context time()

Returns a new `Timer.Context`.

Returns:
  a new `Timer.Context`
See Also:
  `Timer.Context`

#### getElapsedTime

    Duration getElapsedTime()

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

Returns:
  the elapsed time `duration`

#### getCount

    long getCount()

#### getSnapshot

    Snapshot getSnapshot()

Description copied from interface: `Sampling`
Returns a snapshot of the values.

Specified by:
  `getSnapshot` in interface `Sampling`
Returns:
  a snapshot of the values