Package

nl.grons.metrics4

scala

Permalink

package scala

Visibility
  1. Public
  2. All

Type Members

  1. trait ActorInstrumentedLifeCycle extends Actor

    Permalink

    Stackable Actor trait which links Gauge life cycles with the actor life cycle.

    Stackable Actor trait which links Gauge life cycles with the actor life cycle.

    When an actor is restarted, gauges can not be created again under the same name in the same metric registry. By mixing in this trait, all gauges created in this actor will be automatically unregistered before this actor restarts.

    Use it as follows:

    object Application {
      // The application wide metrics registry.
      val metricRegistry = new com.codahale.metrics.MetricRegistry()
    }
    trait Instrumented extends InstrumentedBuilder {
      val metricRegistry = Application.metricRegistry
    }
    
    class ExampleActor extends Actor with Instrumented with ActorInstrumentedLifecycle {
    
      var counter = 0
    
      // The following gauge will automatically unregister before a restart of this actor.
      metrics.gauge("sample-gauge"){
        counter
      }
    
      override def receive = {
        case 'increment =>
          counter += 1
          doWork()
      }
    
      def doWork(): Unit = {
        // etc etc etc
      }
    }
  2. trait ReceiveCounterActor extends Actor

    Permalink

    Stackable actor trait which counts received messages.

    Stackable actor trait which counts received messages.

    Metric name defaults to the class of the actor (e.g. ExampleActor below) + .receiveCounter

    Use it as follows:

    object Application {
      // The application wide metrics registry.
      val metricRegistry = new com.codahale.metrics.MetricRegistry()
    }
    trait Instrumented extends InstrumentedBuilder {
      val metricRegistry = Application.metricRegistry
    }
    
    class ExampleActor extends Actor {
    
      def receive = {
        case _ => doWork()
      }
    }
    
    class InstrumentedExampleActor extends ExampleActor with ReceiveCounterActor with Instrumented
  3. trait ReceiveExceptionMeterActor extends Actor

    Permalink

    Stackable actor trait which meters thrown exceptions.

    Stackable actor trait which meters thrown exceptions.

    Metric name defaults to the class of the actor (e.g. ExampleActor below) + .receiveExceptionMeter

    Use it as follows:

    object Application {
      // The application wide metrics registry.
      val metricRegistry = new com.codahale.metrics.MetricRegistry()
    }
    trait Instrumented extends InstrumentedBuilder {
      val metricRegistry = Application.metricRegistry
    }
    
    class ExampleActor extends Actor {
    
      def receive = {
        case _ => doWork()
      }
    }
    
    class InstrumentedExampleActor extends ExampleActor with ReceiveCounterActor with Instrumented
  4. trait ReceiveTimerActor extends Actor

    Permalink

    Stackable actor trait which times the message receipt.

    Stackable actor trait which times the message receipt.

    Metric name defaults to the class of the actor (e.g. ExampleActor below) + .receiveTimer

    Use it as follows:

    object Application {
      // The application wide metrics registry.
      val metricRegistry = new com.codahale.metrics.MetricRegistry()
    }
    trait Instrumented extends InstrumentedBuilder {
      val metricRegistry = Application.metricRegistry
    }
    
    class ExampleActor extends Actor {
    
      def receive = {
        case _ => doWork()
      }
    }
    
    class InstrumentedExampleActor extends ExampleActor with ReceiveCounterActor with Instrumented

Ungrouped