aboutsummaryrefslogtreecommitdiff
path: root/kamon-play/src/test
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2015-02-12 11:30:06 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2015-02-13 05:15:30 +0100
commitc6bb65535bcc3cc1ff3834a91473ee8dfa6145e8 (patch)
treed7dbe6a1007b168998f167ac74a98744542c6fa8 /kamon-play/src/test
parent6729c9632245328a007332cdcce7d362584d735a (diff)
downloadKamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.tar.gz
Kamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.tar.bz2
Kamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.zip
! all: Kamon now works as a single instance in a companion object.
Diffstat (limited to 'kamon-play/src/test')
-rw-r--r--kamon-play/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala3
-rw-r--r--kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala15
-rw-r--r--kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala12
3 files changed, 14 insertions, 16 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala
index 622c2501..de85743c 100644
--- a/kamon-play/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala
@@ -19,6 +19,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.classic.{ AsyncAppender, LoggerContext }
import ch.qos.logback.core.read.ListAppender
import ch.qos.logback.core.status.NopStatusListener
+import kamon.Kamon
import kamon.trace.TraceLocal
import kamon.trace.TraceLocal.AvailableToMdc
import org.scalatest.BeforeAndAfter
@@ -34,7 +35,7 @@ import scala.concurrent.duration._
import scala.concurrent.{ Await, Future }
class LoggerLikeInstrumentationSpec extends PlaySpec with OneServerPerSuite with BeforeAndAfter {
-
+ Kamon.start()
System.setProperty("config.file", "./kamon-play/src/test/resources/conf/application.conf")
val executor = scala.concurrent.ExecutionContext.Implicits.global
diff --git a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
index 0feecb82..3e199df6 100644
--- a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
@@ -16,8 +16,6 @@
package kamon.play
import kamon.Kamon
-import kamon.http.HttpServerMetrics
-import kamon.metric.{ Metrics, TraceMetrics }
import kamon.metric.instrument.CollectionContext
import kamon.play.action.TraceName
import kamon.trace.TraceLocal.HttpContextKey
@@ -33,13 +31,12 @@ import play.api.test.Helpers._
import play.api.test._
import play.core.Router.{ HandlerDef, Route, Routes }
import play.core.{ DynamicPart, PathPattern, Router, StaticPart }
-import play.libs.Akka
import scala.concurrent.duration._
import scala.concurrent.{ Await, Future }
class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
-
+ Kamon.start()
System.setProperty("config.file", "./kamon-play/src/test/resources/conf/application.conf")
val executor = scala.concurrent.ExecutionContext.Implicits.global
@@ -130,17 +127,17 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
"response to the getRouted Action and normalise the current TraceContext name" in {
Await.result(WS.url("http://localhost:19001/getRouted").get(), 10 seconds)
- Kamon(Metrics)(Akka.system()).find("getRouted.get", "trace") must not be empty
+ Kamon.metrics.find("getRouted.get", "trace") must not be empty
}
"response to the postRouted Action and normalise the current TraceContext name" in {
Await.result(WS.url("http://localhost:19001/postRouted").post("content"), 10 seconds)
- Kamon(Metrics)(Akka.system()).find("postRouted.post", "trace") must not be empty
+ Kamon.metrics.find("postRouted.post", "trace") must not be empty
}
"response to the showRouted Action and normalise the current TraceContext name" in {
Await.result(WS.url("http://localhost:19001/showRouted/2").get(), 10 seconds)
- Kamon(Metrics)(Akka.system()).find("show.some.id.get", "trace") must not be empty
+ Kamon.metrics.find("show.some.id.get", "trace") must not be empty
}
"include HttpContext information for help to diagnose possible errors" in {
@@ -155,7 +152,7 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
"record http server metrics for all processed requests" in {
val collectionContext = CollectionContext(100)
- Kamon(Metrics)(Akka.system()).find("play-server", "http-server").get.collect(collectionContext)
+ Kamon.metrics.find("play-server", "http-server").get.collect(collectionContext)
for (repetition ← 1 to 10) {
Await.result(route(FakeRequest(GET, "/default").withHeaders(traceTokenHeader)).get, 10 seconds)
@@ -169,7 +166,7 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
Await.result(routeWithOnError(FakeRequest(GET, "/error").withHeaders(traceTokenHeader)).get, 10 seconds)
}
- val snapshot = Kamon(Metrics)(Akka.system()).find("play-server", "http-server").get.collect(collectionContext)
+ val snapshot = Kamon.metrics.find("play-server", "http-server").get.collect(collectionContext)
snapshot.counter("GET: /default_200").get.count must be(10)
snapshot.counter("GET: /notFound_404").get.count must be(5)
snapshot.counter("GET: /error_500").get.count must be(5)
diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
index 795453d0..9e87da84 100644
--- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
@@ -17,8 +17,8 @@
package kamon.play
import kamon.Kamon
-import kamon.metric.{ Metrics, EntitySnapshot, TraceMetrics }
-import kamon.trace.{ Tracer, TraceContext, SegmentCategory }
+import kamon.metric.{ EntitySnapshot, TraceMetrics }
+import kamon.trace.{ TraceContext, SegmentCategory }
import org.scalatest.{ Matchers, WordSpecLike }
import org.scalatestplus.play.OneServerPerSuite
import play.api.libs.ws.WS
@@ -26,12 +26,12 @@ import play.api.mvc.Action
import play.api.mvc.Results.Ok
import play.api.test.Helpers._
import play.api.test._
-import play.libs.Akka
import scala.concurrent.Await
import scala.concurrent.duration._
class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPerSuite {
+ Kamon.start()
import kamon.metric.TraceMetricsSpec.SegmentSyntax
System.setProperty("config.file", "./kamon-play/src/test/resources/conf/application.conf")
@@ -66,11 +66,11 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer
}
def newContext(name: String): TraceContext =
- Kamon(Tracer)(Akka.system).newContext(name)
+ Kamon.tracer.newContext(name)
def takeSnapshotOf(traceName: String): EntitySnapshot = {
- val recorder = Kamon(Metrics)(Akka.system()).register(TraceMetrics, traceName).get.recorder
- val collectionContext = Kamon(Metrics)(Akka.system()).buildDefaultCollectionContext
+ val recorder = Kamon.metrics.register(TraceMetrics, traceName).get.recorder
+ val collectionContext = Kamon.metrics.buildDefaultCollectionContext
recorder.collect(collectionContext)
}