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 | c3dc34e0a5c0d796dc5f3278d4c49605b7850d0f (patch) | |
tree | b8986c6d6f909115ba27f7f005447d2144c78b00 /kamon-core/src | |
parent | 6a66fa57ed27d1873b4b152fc482832b78d67db5 (diff) | |
download | Kamon-c3dc34e0a5c0d796dc5f3278d4c49605b7850d0f.tar.gz Kamon-c3dc34e0a5c0d796dc5f3278d4c49605b7850d0f.tar.bz2 Kamon-c3dc34e0a5c0d796dc5f3278d4c49605b7850d0f.zip |
wip
Diffstat (limited to 'kamon-core/src')
-rw-r--r-- | kamon-core/src/main/scala/kamon/newrelic/NewRelicReporting.scala | 20 | ||||
-rw-r--r-- | kamon-core/src/main/scala/test/SimpleRequestProcessor.scala | 2 |
2 files changed, 15 insertions, 7 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) } } diff --git a/kamon-core/src/main/scala/test/SimpleRequestProcessor.scala b/kamon-core/src/main/scala/test/SimpleRequestProcessor.scala index ef657f24..b1727d2b 100644 --- a/kamon-core/src/main/scala/test/SimpleRequestProcessor.scala +++ b/kamon-core/src/main/scala/test/SimpleRequestProcessor.scala @@ -26,7 +26,7 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil path("test"){ uow { complete { - val futures = pipeline(Get("http://10.254.10.57:8000/")).map(r => "Ok") :: pipeline(Get("http://10.254.10.57:8000/")).map(r => "Ok") :: Nil + val futures = pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: Nil Future.sequence(futures).map(l => "Ok") } |