diff options
Diffstat (limited to 'src/main/scala/kamon/metric/Metrics.scala')
-rw-r--r-- | src/main/scala/kamon/metric/Metrics.scala | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/src/main/scala/kamon/metric/Metrics.scala b/src/main/scala/kamon/metric/Metrics.scala index 4cbe25e1..cf04659b 100644 --- a/src/main/scala/kamon/metric/Metrics.scala +++ b/src/main/scala/kamon/metric/Metrics.scala @@ -1,48 +1,14 @@ package kamon.metric -import com.yammer.metrics.core.{MetricName, MetricsRegistry} -import scala.collection.mutable.{HashMap,SynchronizedMap} -import com.yammer.metrics.scala.{Meter, Counter, MetricsGroup, Timer} -import com.yammer.metrics.reporting.{ConsoleReporter, JmxReporter} -import scala.collection.mutable import java.util.concurrent.TimeUnit +import com.codahale.metrics._ -class Metrics { - private lazy val metricsRegistry: MetricsRegistry = new MetricsRegistry() - private lazy val metricsGroup = new MetricsGroup(this.getClass, metricsRegistry) +object Metrics { + val metricsRegistry: MetricRegistry = new MetricRegistry - private lazy val meters = new mutable.HashMap[String, Meter] with SynchronizedMap[String, Meter] - private lazy val timers = new HashMap[String, Timer] with SynchronizedMap[String, Timer] - private lazy val counters = new HashMap[String, Counter] with SynchronizedMap[String, Counter] + val consoleReporter = ConsoleReporter.forRegistry(metricsRegistry) + val newrelicReporter = NewRelicReporter(metricsRegistry) - val consoleReporter = ConsoleReporter.enable(metricsRegistry, 1, TimeUnit.SECONDS) - val newrelicReport = new NewRelicReporter(metricsRegistry, "newrelic-reporter"); - - newrelicReport.run() - newrelicReport.start(1, TimeUnit.SECONDS) - - def incrementCounter(key: String) { - counters.getOrElseUpdate(key, (metricsGroup.counter(s"${key}-counter"))).count - } - - def markMeter(key: String) { - meters.getOrElseUpdate(key, metricsGroup.meter(s"${key}-meter", "actor", "actor-message-counter", TimeUnit.SECONDS)).mark() - } - - def trace[T](key: String)(f: => T): T = { - val timer = timers.getOrElseUpdate(key, (metricsGroup.timer(s"${key}-timer")) ) - timer.time(f) - } - - def markAndCountMeter[T](key: String)(f: => T): T = { - markMeter(key) - f - } - - def traceAndCount[T](key: String)(f: => T): T = { - incrementCounter(key) - trace(key) { - f - } - } + newrelicReporter.start(5, TimeUnit.SECONDS) + consoleReporter.build().start(5, TimeUnit.SECONDS) }
\ No newline at end of file |