diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-15 11:16:21 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-15 11:16:21 +0100 |
commit | cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb (patch) | |
tree | 0f07e794e6fb88e180913a10f57ffaa4e2fa03cc /kamon-akka/src/test | |
parent | 8a532fc8c95a5700721248b6b4f558d9a1dcebcb (diff) | |
download | Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.tar.gz Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.tar.bz2 Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.zip |
! core: move the TraceContext manipulation API to the Tracer companion object.
Diffstat (limited to 'kamon-akka/src/test')
4 files changed, 49 insertions, 49 deletions
diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorCellInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorCellInstrumentationSpec.scala index 8f7ae613..457b8351 100644 --- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorCellInstrumentationSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorCellInstrumentationSpec.scala @@ -20,7 +20,7 @@ import akka.pattern.{ ask, pipe } import akka.routing._ import akka.util.Timeout import kamon.testkit.BaseKamonSpec -import kamon.trace.TraceContext +import kamon.trace.Tracer import scala.concurrent.duration._ @@ -29,18 +29,18 @@ class ActorCellInstrumentationSpec extends BaseKamonSpec("actor-cell-instrumenta "the message passing instrumentation" should { "propagate the TraceContext using bang" in new EchoActorFixture { - val testTraceContext = TraceContext.withContext(newContext("bang-reply")) { + val testTraceContext = Tracer.withContext(newContext("bang-reply")) { ctxEchoActor ! "test" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) } "propagate the TraceContext using tell" in new EchoActorFixture { - val testTraceContext = TraceContext.withContext(newContext("tell-reply")) { + val testTraceContext = Tracer.withContext(newContext("tell-reply")) { ctxEchoActor.tell("test", testActor) - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) @@ -48,37 +48,37 @@ class ActorCellInstrumentationSpec extends BaseKamonSpec("actor-cell-instrumenta "propagate the TraceContext using ask" in new EchoActorFixture { implicit val timeout = Timeout(1 seconds) - val testTraceContext = TraceContext.withContext(newContext("ask-reply")) { + val testTraceContext = Tracer.withContext(newContext("ask-reply")) { // The pipe pattern use Futures internally, so FutureTracing test should cover the underpinnings of it. (ctxEchoActor ? "test") pipeTo (testActor) - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) } "propagate the TraceContext to actors behind a simple router" in new EchoSimpleRouterFixture { - val testTraceContext = TraceContext.withContext(newContext("router-reply")) { + val testTraceContext = Tracer.withContext(newContext("router-reply")) { router.route("test", testActor) - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) } "propagate the TraceContext to actors behind a pool router" in new EchoPoolRouterFixture { - val testTraceContext = TraceContext.withContext(newContext("router-reply")) { + val testTraceContext = Tracer.withContext(newContext("router-reply")) { pool ! "test" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) } "propagate the TraceContext to actors behind a group router" in new EchoGroupRouterFixture { - val testTraceContext = TraceContext.withContext(newContext("router-reply")) { + val testTraceContext = Tracer.withContext(newContext("router-reply")) { group ! "test" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) @@ -116,7 +116,7 @@ class ActorCellInstrumentationSpec extends BaseKamonSpec("actor-cell-instrumenta class TraceContextEcho extends Actor { def receive = { - case msg: String ⇒ sender ! TraceContext.currentContext + case msg: String ⇒ sender ! Tracer.currentContext } } diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala index 21706af9..42a26cdd 100644 --- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorLoggingInstrumentationSpec.scala @@ -21,7 +21,7 @@ import com.typesafe.config.ConfigFactory import kamon.testkit.BaseKamonSpec import kamon.trace.TraceLocal.AvailableToMdc import kamon.trace.logging.MdcKeysSupport -import kamon.trace.{ TraceContextAware, TraceLocal, TraceContext } +import kamon.trace.{Tracer, TraceContextAware, TraceLocal} import org.scalatest.Inspectors import org.slf4j.MDC @@ -39,9 +39,9 @@ class ActorLoggingInstrumentationSpec extends BaseKamonSpec("actor-logging-instr val loggerActor = system.actorOf(Props[LoggerActor]) system.eventStream.subscribe(testActor, classOf[LogEvent]) - val testTraceContext = TraceContext.withContext(newContext("logging")) { + val testTraceContext = Tracer.withContext(newContext("logging")) { loggerActor ! "info" - TraceContext.currentContext + Tracer.currentContext } fishForMessage() { @@ -55,7 +55,7 @@ class ActorLoggingInstrumentationSpec extends BaseKamonSpec("actor-logging-instr "allow retrieve a value from the MDC when was created a key of type AvailableToMdc" in { val testString = "Hello World" - TraceContext.withContext(newContext("logging-with-mdc")) { + Tracer.withContext(newContext("logging-with-mdc")) { TraceLocal.store(AvailableToMdc("some-cool-key"))(testString) withMdc { @@ -71,6 +71,6 @@ class ActorLoggingInstrumentationSpec extends BaseKamonSpec("actor-logging-instr class LoggerActor extends Actor with ActorLogging { def receive = { - case "info" ⇒ log.info("TraceContext(name = {}, token = {})", TraceContext.currentContext.name, TraceContext.currentContext.token) + case "info" ⇒ log.info("TraceContext(name = {}, token = {})", Tracer.currentContext.name, Tracer.currentContext.token) } } diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala index 808473cd..fd9f58d0 100644 --- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/ActorSystemMessageInstrumentationSpec.scala @@ -21,7 +21,7 @@ import akka.actor._ import akka.testkit.ImplicitSender import com.typesafe.config.ConfigFactory import kamon.testkit.BaseKamonSpec -import kamon.trace.{ EmptyTraceContext, TraceContext } +import kamon.trace.{Tracer, EmptyTraceContext} import org.scalatest.WordSpecLike import scala.concurrent.duration._ @@ -40,31 +40,31 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- "the system message passing instrumentation" should { "keep the TraceContext while processing the Create message in top level actors" in { - val testTraceContext = TraceContext.withContext(newContext("creating-top-level-actor")) { + val testTraceContext = Tracer.withContext(newContext("creating-top-level-actor")) { system.actorOf(Props(new Actor { - testActor ! TraceContext.currentContext + testActor ! Tracer.currentContext def receive: Actor.Receive = { case any ⇒ } })) - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) } "keep the TraceContext while processing the Create message in non top level actors" in { - val testTraceContext = TraceContext.withContext(newContext("creating-non-top-level-actor")) { + val testTraceContext = Tracer.withContext(newContext("creating-non-top-level-actor")) { system.actorOf(Props(new Actor { def receive: Actor.Receive = { case any ⇒ context.actorOf(Props(new Actor { - testActor ! TraceContext.currentContext + testActor ! Tracer.currentContext def receive: Actor.Receive = { case any ⇒ } })) } })) ! "any" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) @@ -74,9 +74,9 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- "the actor is resumed" in { val supervisor = supervisorWithDirective(Resume) - val testTraceContext = TraceContext.withContext(newContext("fail-and-resume")) { + val testTraceContext = Tracer.withContext(newContext("fail-and-resume")) { supervisor ! "fail" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) // From the parent executing the supervision strategy @@ -89,9 +89,9 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- "the actor is restarted" in { val supervisor = supervisorWithDirective(Restart, sendPreRestart = true, sendPostRestart = true) - val testTraceContext = TraceContext.withContext(newContext("fail-and-restart")) { + val testTraceContext = Tracer.withContext(newContext("fail-and-restart")) { supervisor ! "fail" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) // From the parent executing the supervision strategy @@ -106,9 +106,9 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- "the actor is stopped" in { val supervisor = supervisorWithDirective(Stop, sendPostStop = true) - val testTraceContext = TraceContext.withContext(newContext("fail-and-stop")) { + val testTraceContext = Tracer.withContext(newContext("fail-and-stop")) { supervisor ! "fail" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) // From the parent executing the supervision strategy @@ -119,9 +119,9 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- "the failure is escalated" in { val supervisor = supervisorWithDirective(Escalate, sendPostStop = true) - val testTraceContext = TraceContext.withContext(newContext("fail-and-escalate")) { + val testTraceContext = Tracer.withContext(newContext("fail-and-escalate")) { supervisor ! "fail" - TraceContext.currentContext + Tracer.currentContext } expectMsg(testTraceContext) // From the parent executing the supervision strategy @@ -139,7 +139,7 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- val child = context.actorOf(Props(new Parent)) override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() { - case NonFatal(throwable) ⇒ testActor ! TraceContext.currentContext; Stop + case NonFatal(throwable) ⇒ testActor ! Tracer.currentContext; Stop } def receive = { @@ -151,7 +151,7 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- val child = context.actorOf(Props(new Child)) override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() { - case NonFatal(throwable) ⇒ testActor ! TraceContext.currentContext; directive + case NonFatal(throwable) ⇒ testActor ! Tracer.currentContext; directive } def receive: Actor.Receive = { @@ -159,7 +159,7 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- } override def postStop(): Unit = { - if (sendPostStop) testActor ! TraceContext.currentContext + if (sendPostStop) testActor ! Tracer.currentContext super.postStop() } } @@ -167,26 +167,26 @@ class ActorSystemMessageInstrumentationSpec extends BaseKamonSpec("actor-system- class Child extends Actor { def receive = { case "fail" ⇒ throw new ArithmeticException("Division by zero.") - case "context" ⇒ sender ! TraceContext.currentContext + case "context" ⇒ sender ! Tracer.currentContext } override def preRestart(reason: Throwable, message: Option[Any]): Unit = { - if (sendPreRestart) testActor ! TraceContext.currentContext + if (sendPreRestart) testActor ! Tracer.currentContext super.preRestart(reason, message) } override def postRestart(reason: Throwable): Unit = { - if (sendPostRestart) testActor ! TraceContext.currentContext + if (sendPostRestart) testActor ! Tracer.currentContext super.postRestart(reason) } override def postStop(): Unit = { - if (sendPostStop) testActor ! TraceContext.currentContext + if (sendPostStop) testActor ! Tracer.currentContext super.postStop() } override def preStart(): Unit = { - if (sendPreStart) testActor ! TraceContext.currentContext + if (sendPreStart) testActor ! Tracer.currentContext super.preStart() } } diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala index 44b90642..a44945ea 100644 --- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala @@ -27,7 +27,7 @@ import com.typesafe.config.ConfigFactory import kamon.Kamon import kamon.akka.Akka import kamon.testkit.BaseKamonSpec -import kamon.trace.{ TraceContext, TraceContextAware } +import kamon.trace.{Tracer, TraceContext, TraceContextAware} import scala.concurrent.duration._ @@ -51,9 +51,9 @@ class AskPatternInstrumentationSpec extends BaseKamonSpec("ask-pattern-tracing-s setAskPatternTimeoutWarningMode("heavyweight") expectTimeoutWarning() { - TraceContext.withContext(newContext("ask-timeout-warning")) { + Tracer.withContext(newContext("ask-timeout-warning")) { noReplyActorRef ? "hello" - TraceContext.currentContext + Tracer.currentContext } } } @@ -64,9 +64,9 @@ class AskPatternInstrumentationSpec extends BaseKamonSpec("ask-pattern-tracing-s setAskPatternTimeoutWarningMode("lightweight") expectTimeoutWarning(messageSizeLimit = Some(1)) { - TraceContext.withContext(newContext("ask-timeout-warning")) { + Tracer.withContext(newContext("ask-timeout-warning")) { noReplyActorRef ? "hello" - TraceContext.currentContext + Tracer.currentContext } } } @@ -77,9 +77,9 @@ class AskPatternInstrumentationSpec extends BaseKamonSpec("ask-pattern-tracing-s setAskPatternTimeoutWarningMode("off") expectTimeoutWarning(expectWarning = false) { - TraceContext.withContext(newContext("ask-timeout-warning")) { + Tracer.withContext(newContext("ask-timeout-warning")) { noReplyActorRef ? "hello" - TraceContext.currentContext + Tracer.currentContext } } } |