From 2caece9ef7574406c548b4a1f333de4c9579b3a2 Mon Sep 17 00:00:00 2001 From: Diego Parra Date: Fri, 3 May 2013 17:06:10 -0300 Subject: Initial Commit Kamon --- src/main/scala/kamon/metric/NewRelicReporter.scala | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/scala/kamon/metric/NewRelicReporter.scala (limited to 'src/main/scala/kamon/metric/NewRelicReporter.scala') diff --git a/src/main/scala/kamon/metric/NewRelicReporter.scala b/src/main/scala/kamon/metric/NewRelicReporter.scala new file mode 100644 index 00000000..9aa374aa --- /dev/null +++ b/src/main/scala/kamon/metric/NewRelicReporter.scala @@ -0,0 +1,41 @@ +package kamon.metric + +import com.newrelic.api.agent.NewRelic +import com.yammer.metrics.reporting.AbstractPollingReporter +import com.yammer.metrics.core._ + + +class NewRelicReporter(registry: MetricsRegistry, name: String) extends AbstractPollingReporter(registry, name) with MetricProcessor[String] { + + + + def processMeter(name: MetricName, meter: Metered, context: String) { + println(s"Logging to NewRelic: ${meter.count()}") + NewRelic.recordMetric("Custom/Actor/MessagesPerSecond", meter.count()) + } + + + def processCounter(name: MetricName, counter: Counter, context: String) {} + + def processHistogram(name: MetricName, histogram: Histogram, context: String) {} + + def processTimer(name: MetricName, timer: Timer, context: String) {} + + def processGauge(name: MetricName, gauge: Gauge[_], context: String) {} + + private final val predicate: MetricPredicate = null + + + def run() { + import scala.collection.JavaConversions._ + for (entry <- getMetricsRegistry.groupedMetrics(predicate).entrySet) { + import scala.collection.JavaConversions._ + for (subEntry <- entry.getValue.entrySet) { + subEntry.getValue.processWith(this, subEntry.getKey, "") + } + + } + + } + +} -- cgit v1.2.3