diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon/newrelic')
-rw-r--r-- | kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala b/kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala index 6629e164..106f27e2 100644 --- a/kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala +++ b/kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala @@ -5,6 +5,7 @@ import kamon.trace.UowTrace import com.newrelic.api.agent.{Response, Request, Trace, NewRelic} import kamon.trace.UowTracing.{WebExternal, WebExternalFinish, WebExternalStart} import java.util +import java.util.Date class NewRelicReporting extends Actor { @@ -22,23 +23,30 @@ class NewRelicReporting extends Actor { uowTrace.segments.collect { case we: WebExternal => we }.foreach { webExternalTrace => val external = ((webExternalTrace.finish - webExternalTrace.start)/1E9).toFloat + println("Web External: " + webExternalTrace) NewRelic.recordMetric(s"External/${webExternalTrace.host}/http", external) NewRelic.recordMetric(s"External/${webExternalTrace.host}/all", external) NewRelic.recordMetric(s"External/${webExternalTrace.host}/http/WebTransaction/Custom" + uowTrace.name, external) } -/* - - val allExternals = uowTrace.segments.collect { case we: WebExternal => we } sortBy(_.timestamp) - def measureExternal(segments: Seq[WebExternal]): Long = { + val allExternals = uowTrace.segments.collect { case we: WebExternal => we } sortBy(_.timestamp) + def measureExternal(accum: Long, lastEnd: Long, segments: Seq[WebExternal]): Long = segments match { + case Nil => accum + case head :: tail => + if(head.start > lastEnd) + measureExternal(accum + (head.finish-head.start), head.finish, tail) + else + measureExternal(accum + (head.finish-lastEnd), head.finish, tail) } + val external = measureExternal(0, 0, allExternals) / 1E9 + - NewRelic.recordMetric(s"External/all", external) - NewRelic.recordMetric(s"External/allWeb", external)*/ + NewRelic.recordMetric(s"External/all", external.toFloat) + NewRelic.recordMetric(s"External/allWeb", external.toFloat) } } |