diff options
Diffstat (limited to 'kamon-newrelic/src/main')
-rw-r--r-- | kamon-newrelic/src/main/scala/kamon/newrelic/AgentJsonProtocol.scala | 2 | ||||
-rw-r--r-- | kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/AgentJsonProtocol.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/AgentJsonProtocol.scala index ecb8ff09..9b3e6dea 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/AgentJsonProtocol.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/AgentJsonProtocol.scala @@ -58,6 +58,6 @@ object AgentJsonProtocol extends DefaultJsonProtocol { JsNumber(obj.runId), JsNumber(obj.timeSliceMetrics.from), JsNumber(obj.timeSliceMetrics.to), - obj.timeSliceMetrics.metrics.toJson) + obj.timeSliceMetrics.metrics.values.toSeq.toJson) } } diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala index 6313a2aa..5fa571e1 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala @@ -28,16 +28,19 @@ class MetricTranslator(receiver: ActorRef) extends Actor val fromInSeconds = (from / 1E3).toInt val toInSeconds = (to / 1E3).toInt val allMetrics = collectWebTransactionMetrics(metrics) ++ collectCustomMetrics(metrics) + val groupedMetrics: Map[String, NewRelic.Metric] = allMetrics.map(metric ⇒ metric.name -> metric)(collection.breakOut) // avoid intermediate tuple - receiver ! TimeSliceMetrics(fromInSeconds, toInSeconds, allMetrics) + receiver ! TimeSliceMetrics(fromInSeconds, toInSeconds, groupedMetrics) } } object MetricTranslator { - case class TimeSliceMetrics(from: Long, to: Long, metrics: Seq[NewRelic.Metric]) { + case class TimeSliceMetrics(from: Long, to: Long, metrics: Map[String, NewRelic.Metric]) { + import kamon.metric._ + def merge(thatMetrics: Option[TimeSliceMetrics]): TimeSliceMetrics = { - thatMetrics.map(that ⇒ TimeSliceMetrics(from + that.from, to + that.to, metrics ++ that.metrics)).getOrElse(this) + thatMetrics.map(that ⇒ TimeSliceMetrics(from + that.from, to + that.to, combineMaps(metrics, that.metrics)((l, r) ⇒ l.merge(r)))).getOrElse(this) } } |