exceptionMarkerPF

nl.grons.metrics4.scala.Meter.exceptionMarkerPF

Converts partial function pf into a side-effecting partial function that meters thrown exceptions for every invocation of pf (for the cases 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"
    case 5 => throw new IllegalArgumentException("5 is unlucky")
  }

  val isEvenExceptionMeter = metrics.meter("isEvenExceptions")
  val meteredIsEven: PartialFunction[Int, String] = isEvenExceptionMeter.exceptionMarkerPF(isEven)

  val sample = 1 to 10
  sample collect meteredIsEven   // the meter counts 1 exception
}

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def apply[A, B](pf: PartialFunction[A, B]): PartialFunction[A, B]