diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-10-11 18:14:33 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-10-11 18:14:33 -0300 |
commit | 944ef29716d26910998ee20d4ff842301598e81b (patch) | |
tree | cb51d799f880758e591e13405117415dc7b7e4cf /kamon-core/src/main/scala/kamon/newrelic | |
parent | e148933747e8fde17b6ac324df0dee70b8cb9ebc (diff) | |
download | Kamon-944ef29716d26910998ee20d4ff842301598e81b.tar.gz Kamon-944ef29716d26910998ee20d4ff842301598e81b.tar.bz2 Kamon-944ef29716d26910998ee20d4ff842301598e81b.zip |
wip
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) } } |