Class 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 via Meter. The timer measures duration in nanoseconds.
    • Method Detail

      • update

        public void update​(long duration,
                           TimeUnit unit)
        Adds a recorded duration.
        Parameters:
        duration - the length of the duration
        unit - the scale unit of duration
      • update

        public void update​(Duration duration)
        Specified by:
        update in interface org.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 interface org.eclipse.microprofile.metrics.Timer
        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

        public void time​(Runnable event)
        Times and records the duration of event.
        Specified by:
        time in interface org.eclipse.microprofile.metrics.Timer
        Parameters:
        event - a Runnable whose Runnable.run() method implements a process whose duration should be timed
      • time

        public org.eclipse.microprofile.metrics.Timer.Context time()
        Returns a new TimerImpl.Context.
        Specified by:
        time in interface org.eclipse.microprofile.metrics.Timer
        Returns:
        a new TimerImpl.Context
        See Also:
        TimerImpl.Context
      • getElapsedTime

        public Duration getElapsedTime()
        Specified by:
        getElapsedTime in interface org.eclipse.microprofile.metrics.Timer
      • getCount

        public long getCount()
        Specified by:
        getCount in interface org.eclipse.microprofile.metrics.Counting
        Specified by:
        getCount in interface org.eclipse.microprofile.metrics.Metered
        Specified by:
        getCount in interface org.eclipse.microprofile.metrics.Timer
      • getFifteenMinuteRate

        public double getFifteenMinuteRate()
        Specified by:
        getFifteenMinuteRate in interface org.eclipse.microprofile.metrics.Metered
        Specified by:
        getFifteenMinuteRate in interface org.eclipse.microprofile.metrics.Timer
      • getFiveMinuteRate

        public double getFiveMinuteRate()
        Specified by:
        getFiveMinuteRate in interface org.eclipse.microprofile.metrics.Metered
        Specified by:
        getFiveMinuteRate in interface org.eclipse.microprofile.metrics.Timer
      • getMeanRate

        public double getMeanRate()
        Specified by:
        getMeanRate in interface org.eclipse.microprofile.metrics.Metered
        Specified by:
        getMeanRate in interface org.eclipse.microprofile.metrics.Timer
      • getOneMinuteRate

        public double getOneMinuteRate()
        Specified by:
        getOneMinuteRate in interface org.eclipse.microprofile.metrics.Metered
        Specified by:
        getOneMinuteRate in interface org.eclipse.microprofile.metrics.Timer
      • getSnapshot

        public org.eclipse.microprofile.metrics.Snapshot getSnapshot()
        Specified by:
        getSnapshot in interface org.eclipse.microprofile.metrics.Sampling
        Specified by:
        getSnapshot in interface org.eclipse.microprofile.metrics.Timer