aboutsummaryrefslogtreecommitdiff
path: root/kamon-play/src/test/scala
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2014-05-09 18:23:21 -0300
committerDiego <diegolparra@gmail.com>2014-05-09 18:23:21 -0300
commit0ce3f4c0e8eb7dfd4aadd8300880e001a9a9bb8d (patch)
treef4f08e425ddb7261ddd34d69e78315292e7cbdda /kamon-play/src/test/scala
parente7d18421c354d4dbc3c5b77073fb0b195eb45cfe (diff)
downloadKamon-0ce3f4c0e8eb7dfd4aadd8300880e001a9a9bb8d.tar.gz
Kamon-0ce3f4c0e8eb7dfd4aadd8300880e001a9a9bb8d.tar.bz2
Kamon-0ce3f4c0e8eb7dfd4aadd8300880e001a9a9bb8d.zip
+ play: removed default dispatchers to kamon default dispatcher and refactor test in WSInstrumentationSpec
Diffstat (limited to 'kamon-play/src/test/scala')
-rw-r--r--kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala52
1 files changed, 47 insertions, 5 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
index 4b31fb25..0c3783bb 100644
--- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
@@ -19,25 +19,67 @@ package kamon.play
import play.api.mvc.Action
import play.api.mvc.Results.Ok
import play.api.libs.ws.WS
-import org.scalatestplus.play.{ OneServerPerSuite, PlaySpec }
+import org.scalatestplus.play.OneServerPerSuite
import play.api.test._
import play.api.test.Helpers._
+import akka.actor.ActorSystem
+import akka.testkit.{ TestKitBase, TestProbe }
-class WSInstrumentationSpec extends PlaySpec with OneServerPerSuite {
+import com.typesafe.config.ConfigFactory
+import org.scalatest.{ Matchers, WordSpecLike }
+import kamon.Kamon
+import kamon.metrics.{ TraceMetrics, Metrics }
+import kamon.metrics.Subscriptions.TickMetricSnapshot
+import kamon.metrics.TraceMetrics.ElapsedTime
+
+class WSInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers with OneServerPerSuite {
System.setProperty("config.file", "./kamon-play/src/test/resources/conf/application.conf")
+ import scala.collection.immutable.StringLike._
+ implicit lazy val system: ActorSystem = ActorSystem("play-ws-instrumentation-spec", ConfigFactory.parseString(
+ """
+ |akka {
+ | loglevel = ERROR
+ |}
+ |
+ |kamon {
+ | metrics {
+ | tick-interval = 2 seconds
+ |
+ | filters = [
+ | {
+ | trace {
+ | includes = [ "*" ]
+ | excludes = []
+ | }
+ | }
+ | ]
+ | }
+ |}
+ """.stripMargin))
+
implicit override lazy val app = FakeApplication(withRoutes = {
case ("GET", "/async") ⇒ Action { Ok("ok") }
})
"the WS instrumentation" should {
"respond to the Async Action and complete the WS request" in {
- val response = await(WS.url("http://localhost:19001/async").get())
- response.status mustBe (OK)
+ val metricListener = TestProbe()
+ Kamon(Metrics)(system).subscribe(TraceMetrics, "*", metricListener.ref, permanently = true)
+ metricListener.expectMsgType[TickMetricSnapshot]
+
+ val response = await(WS.url("http://localhost:19001/async").get())
+ response.status should be(OK)
- //Thread.sleep(2000) //wait to complete the future
+ // val tickSnapshot = metricListener.expectMsgType[TickMetricSnapshot]
+ // val traceMetrics = tickSnapshot.metrics.find { case (k, v) ⇒ k.name.contains("async") } map (_._2.metrics)
+ // traceMetrics should not be empty
+ //
+ // traceMetrics map { metrics ⇒
+ // metrics(ElapsedTime).numberOfMeasurements should be(1L)
+ // }
}
}
} \ No newline at end of file