diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-01-27 09:11:32 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-01-27 09:11:32 -0300 |
commit | 003af1dd8ef1e3b4a8f1a9eff56a3c15c01cb2a9 (patch) | |
tree | e0afcb7d2358787f16c5b19e8caceaab5d6ea1ca /kamon-spray/src/test/scala/kamon/spray | |
parent | fc13a7e4abf87c92d63cb7b13561119b6414651e (diff) | |
download | Kamon-003af1dd8ef1e3b4a8f1a9eff56a3c15c01cb2a9.tar.gz Kamon-003af1dd8ef1e3b4a8f1a9eff56a3c15c01cb2a9.tar.bz2 Kamon-003af1dd8ef1e3b4a8f1a9eff56a3c15c01cb2a9.zip |
rename UOW to TraceToken and generate it by default when a Trace starts
Diffstat (limited to 'kamon-spray/src/test/scala/kamon/spray')
-rw-r--r-- | kamon-spray/src/test/scala/kamon/spray/ClientRequestTracingSpec.scala | 2 | ||||
-rw-r--r-- | kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala | 37 |
2 files changed, 27 insertions, 12 deletions
diff --git a/kamon-spray/src/test/scala/kamon/spray/ClientRequestTracingSpec.scala b/kamon-spray/src/test/scala/kamon/spray/ClientRequestTracingSpec.scala index c7ec2a5f..eae0c992 100644 --- a/kamon-spray/src/test/scala/kamon/spray/ClientRequestTracingSpec.scala +++ b/kamon-spray/src/test/scala/kamon/spray/ClientRequestTracingSpec.scala @@ -14,7 +14,7 @@ class ClientRequestTracingSpec extends TestKit(ActorSystem("server-request-traci "the client instrumentation" should { "record segments for a client http request" in { - Trace.start("record-segments")(system) + Trace.start("record-segments", None)(system) send { Get(s"http://127.0.0.1:$port/ok") diff --git a/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala b/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala index 44ed3baf..2a2865e1 100644 --- a/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala +++ b/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala @@ -19,25 +19,33 @@ import _root_.spray.httpx.RequestBuilding import _root_.spray.routing.SimpleRoutingApp import akka.testkit.TestKit import akka.actor.ActorSystem -import org.scalatest.WordSpecLike +import org.scalatest.{ Matchers, WordSpecLike } import scala.concurrent.Await import scala.concurrent.duration._ import _root_.spray.client.pipelining._ import akka.util.Timeout import kamon.trace.{ UowTrace, Trace } import kamon.Kamon +import org.scalatest.concurrent.{ PatienceConfiguration, ScalaFutures } +import spray.http.HttpHeaders.RawHeader +import spray.http.HttpRequest +import spray.http.HttpHeaders.Host -class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-tracing-spec")) with WordSpecLike with RequestBuilding with TestServer { +class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-tracing-spec")) with WordSpecLike with Matchers with RequestBuilding with ScalaFutures with PatienceConfiguration with TestServer { "the spray server request tracing instrumentation" should { "trace a request start/finish sequence when proper TraceContext is received" in { - send { - Get(s"http://127.0.0.1:$port/ok") + val response = send { + Get("/ok") } within(5 seconds) { fishForNamedTrace("ok") } + + whenReady(response) { rsp ⇒ + rsp.headers should contain(RawHeader("X-Trace-Token", "")) + } } "finish a request even if no TraceContext is received in the response" in { @@ -60,6 +68,10 @@ class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-traci } } } + /* + - si no llega uow, crear una + - si llega con uow hay que propagarla + */ def fishForNamedTrace(traceName: String) = fishForMessage() { case trace: UowTrace if trace.name.contains(traceName) ⇒ true @@ -79,15 +91,18 @@ trait TestServer extends SimpleRoutingApp { path("ok") { complete("ok") } ~ - path("clearcontext") { - complete { - println("The Context in the route is: " + Trace.context) - Trace.clear - "ok" - } + path("clearcontext") { + complete { + Trace.clear + "ok" } + } }), timeout.duration).localAddress.getPort - val send = sendReceive(system, system.dispatcher, timeout) + val send = includeHost("127.0.0.1", port) ~> sendReceive(system, system.dispatcher, timeout) + + def includeHost(host: String, port: Int) = { request: HttpRequest ⇒ + request.withEffectiveUri(port == 443, Host(host, port)) + } } |