class Timer extends AnyRef

A Scala facade class for DropwizardTimer.

Features: * measure the execution duration of a block of code with time() * measure the time until a future is completed with timeFuture() * add an execution duration measurement as a side effect to a partial function with timePF() * direct access to the underlying timer with update(), timerContext(), count, max, etc.

Example usage:

class Example(val db: Db) extends Instrumented {
  private[this] val loadTimer = metrics.timer("load")

  def load(id: Long) = loadTimer.time {
    db.load(id)
  }
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Timer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Timer(metric: com.codahale.metrics.Timer)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. def count: Long

    The number of durations recorded.

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def fifteenMinuteRate: Double

    The fifteen-minute rate of timings.

  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. def fiveMinuteRate: Double

    The five-minute rate of timings.

  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def max: Long

    The longest recorded duration in nanoseconds.

  16. def mean: Double

    The arithmetic mean of all recorded durations in nanoseconds.

  17. def meanRate: Double

    The mean rate of timings.

  18. def min: Long

    The shortest recorded duration in nanoseconds.

  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def oneMinuteRate: Double

    The one-minute rate of timings.

  23. def snapshot: Snapshot

    A snapshot of the values in the timer's sample.

  24. def stdDev: Double

    The standard deviation of all recorded durations.

  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def time[A](f: => A): A

    Runs f, recording its duration, and returns its result.

  27. def timeFuture[A](future: => Future[A])(implicit context: ExecutionContext): Future[A]

    Measures 'now' up to the moment that the given future completes, then updates this timer with the measurement.

    Measures 'now' up to the moment that the given future completes, then updates this timer with the measurement.

    *Know what you measure*

    This method may measure more than is obvious. It measures: * the evaluation of the (by name) parameter future * in case the future is not yet completed: the delay until the constructed Future is scheduled in the given ExecutionContext * in case the future is not yet completed: the actual execution of the Future * the time it takes to schedule stopping the timer

    To only measure the Future execution time, please use a timer in the code that is executed inside the Future.

    The timer is stopped concurrently to the returned future. If you need to verify the timer's value in a unit test you can use something like ScalaTest's eventually, or use a direct execution context. For more information see [https://github.com/erikvanoosten/metrics-scala/pull/144].

    Example usage:

    class Example extends Instrumented {
      private[this] loadTimer = metrics.timer("loading")
    
      private def asyncFetchRows(): Future[Seq[Row]] = ...
    
      def loadStuffEventually(): Future[Seq[Row]] = loadTimer.timeFuture { asyncFetchRows() }
    }
    A

    future result type

    future

    the expression that results in a future

    context

    execution context

    returns

    the result of executing future

  28. def timePF[A, B](pf: PartialFunction[A, B]): PartialFunction[A, B]

    Converts partial function pf into a side-effecting partial function that times every invocation of pf for which it is defined.

    Converts partial function pf into a side-effecting partial function that times every invocation of pf for which it is defined. The result is passed unchanged.

    Example usage:

    class Example extends Instrumented {
      val isEven: PartialFunction[Int, String] = {
        case x if x % 2 == 0 => x+" is even"
      }
    
      val isEvenTimer = metrics.timer("isEven")
      val timedIsEven: PartialFunction[Int, String] = isEvenTimer.timePF(isEven)
    
      val sample = 1 to 10
      sample collect timedIsEven   // timer does 5 measurements
    }
  29. def timerContext(): Context

    A timing com.codahale.metrics.Timer.Context, which measures an elapsed time in nanoseconds.

  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. def update(duration: Long, unit: TimeUnit): Unit

    Adds a recorded duration.

  32. def update(duration: FiniteDuration): Unit

    Adds a recorded duration.

  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped