nl.grons.metrics.scala
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.
The MetricRegistry where created metrics are registered.
The base name for all metrics created from this builder.
The MetricBuilder that can be used for creating timers, counters, etc.
The mixin trait for creating a class which is instrumented with metrics.
Use it as follows:
It is also possible to override the metric base name. For example:
If you want to use hdrhistograms, you can override the metric builder as follows:
See the the manual for more instructions on using hdrhistogram.