Stackable Actor trait which links Gauge life cycles with the actor life cycle.
Provides a wrapper for by-name expressions with the intent that they can become eligible for implicit conversions and implicit resolution.
Provides a wrapper for by-name expressions with the intent that they can become eligible for implicit conversions and implicit resolution.
Result type of the evaluated expression
The mixin trait for creating a class which creates health checks.
A Scala facade class for DropwizardCounter.
A Scala facade class for DropwizardGauge.
An alternative metric builder that creates Histograms and Timers with Reservoirs from the HdrHistogram library.
An alternative metric builder that creates Histograms and Timers with Reservoirs from the HdrHistogram library.
See the the manual for more instructions on using hdrhistogram.
Magnet for the checker.
Magnet for the checker. See http://spray.io/blog/2012-12-13-the-magnet-pattern/.
A Scala facade class for DropwizardHistogram.
The mixin trait for creating a class which is instrumented with metrics.
The mixin trait for creating a class which is instrumented with metrics.
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 Example(db: Database) extends Instrumented { private[this] val loading = metrics.timer("loading") def loadStuff(): Seq[Row] = loading.time { db.fetchRows() } }
It is also possible to override the metric base name. For example:
class Example(db: Database) extends Instrumented { override lazy val metricBaseName = MetricName("Overridden.Base.Name") private[this] val loading = metrics.timer("loading") def loadStuff(): Seq[Row] = loading.time { db.fetchRows() } }
If you want to use hdrhistograms, you can override the metric builder as follows:
trait Instrumented extends InstrumentedBuilder { override lazy protected val metricBuilder = new HdrMetricBuilder(metricBaseName, metricRegistry, false) val metricRegistry = Application.metricRegistry }
See the the manual for more instructions on using hdrhistogram.
A Scala facade class for DropwizardMeter.
A Scala facade class for DropwizardMeter.
Example usage:
class Example(val db: Db) extends Instrumented { private[this] val rowsLoadedMeter = metrics.meter("rowsLoaded") def load(id: Long): Seq[Row] = { val rows = db.load(id) rowsLoaded.mark(rows.size) rows } }
Builds and registering metrics.
The (base)name of a metric.
The (base)name of a metric.
Constructed via the companion object, e.g. MetricName(getClass, "requests").
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
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
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
A Scala facade class for DropwizardTimer.
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) } }
(Since version 3.5.4) Please use Timer.time() or Timer.timeFuture()
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: