aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/kamon/metric/NewRelicReporter.scala
blob: fa6b29f3db2f809d8cf436e0f02faf154079a99e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package kamon.metric

import com.newrelic.api.agent.NewRelic
import com.yammer.metrics.reporting.AbstractPollingReporter
import com.yammer.metrics.core._
import scala.collection.JavaConversions._


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) {}


  def run() {
    for (entry <- getMetricsRegistry.groupedMetrics(MetricPredicate.ALL).entrySet) {
      for (subEntry <- entry.getValue.entrySet) {
        subEntry.getValue.processWith(this, subEntry.getKey, "")
      }
    }
  }
}