Class SimpleTimerImpl

  • All Implemented Interfaces:
    org.eclipse.microprofile.metrics.Counting, org.eclipse.microprofile.metrics.Metric, org.eclipse.microprofile.metrics.SimpleTimer

    public class SimpleTimerImpl
    extends Object
    implements org.eclipse.microprofile.metrics.SimpleTimer
    • Constructor Detail

      • SimpleTimerImpl

        public SimpleTimerImpl​(Clock clock)
        Creates a new SimpleTimerImpl that uses the given Clock.
        Parameters:
        clock - the Clock implementation the timer should use
    • Method Detail

      • update

        public void update​(Duration duration)
        Adds a recorded duration.
        Specified by:
        update in interface org.eclipse.microprofile.metrics.SimpleTimer
        Parameters:
        duration - the length of the duration
      • 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.SimpleTimer
        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.SimpleTimer
        Parameters:
        event - a Runnable whose Runnable.run() method implements a process whose duration should be timed
      • getCount

        public long getCount()
        Specified by:
        getCount in interface org.eclipse.microprofile.metrics.Counting
        Specified by:
        getCount in interface org.eclipse.microprofile.metrics.SimpleTimer
      • getElapsedTime

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

        public Duration getMaxTimeDuration()
        Specified by:
        getMaxTimeDuration in interface org.eclipse.microprofile.metrics.SimpleTimer
      • getMinTimeDuration

        public Duration getMinTimeDuration()
        Specified by:
        getMinTimeDuration in interface org.eclipse.microprofile.metrics.SimpleTimer