Class StepFunctionTimer<T>

  • All Implemented Interfaces:
    FunctionTimer, Meter

    public class StepFunctionTimer<T>
    extends java.lang.Object
    implements FunctionTimer
    A timer that tracks monotonically increasing functions for count and totalTime.
    • Constructor Summary

      Constructors 
      Constructor Description
      StepFunctionTimer​(Meter.Id id, Clock clock, long stepMillis, T obj, java.util.function.ToLongFunction<T> countFunction, java.util.function.ToDoubleFunction<T> totalTimeFunction, java.util.concurrent.TimeUnit totalTimeFunctionUnit, java.util.concurrent.TimeUnit baseTimeUnit)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.TimeUnit baseTimeUnit()  
      double count()
      The total number of occurrences of the timed event.
      Meter.Id getId()  
      double totalTime​(java.util.concurrent.TimeUnit unit)
      The total time of all occurrences of the timed event.
      Meter.Type type()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StepFunctionTimer

        public StepFunctionTimer​(Meter.Id id,
                                 Clock clock,
                                 long stepMillis,
                                 T obj,
                                 java.util.function.ToLongFunction<T> countFunction,
                                 java.util.function.ToDoubleFunction<T> totalTimeFunction,
                                 java.util.concurrent.TimeUnit totalTimeFunctionUnit,
                                 java.util.concurrent.TimeUnit baseTimeUnit)
    • Method Detail

      • count

        public double count()
        The total number of occurrences of the timed event.
        Specified by:
        count in interface FunctionTimer
        Returns:
        The total number of occurrences of the timed event.
      • totalTime

        public double totalTime​(java.util.concurrent.TimeUnit unit)
        The total time of all occurrences of the timed event.
        Specified by:
        totalTime in interface FunctionTimer
        Parameters:
        unit - The base unit of time to scale the total to.
        Returns:
        The total time of all occurrences of the timed event.
      • getId

        public Meter.Id getId()
        Specified by:
        getId in interface Meter
        Returns:
        A unique combination of name and tags
      • baseTimeUnit

        public java.util.concurrent.TimeUnit baseTimeUnit()
        Specified by:
        baseTimeUnit in interface FunctionTimer
        Returns:
        The base time unit of the timer to which all published metrics will be scaled