aboutsummaryrefslogtreecommitdiff
path: root/kamon-akka-remote/src/test/scala/kamon
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2015-01-12 01:45:27 +0100
committerIvan Topolnjak <ivantopo@gmail.com>2015-01-24 23:19:01 +0100
commit01a34f67ff75419c440f2e69c0a0db888a670a34 (patch)
tree9c4dee4e9c13c26937356950f9e4927c3f9dfb7d /kamon-akka-remote/src/test/scala/kamon
parent4a47e92d23af371f1d50b40af6cbe00a5ffc0105 (diff)
downloadKamon-01a34f67ff75419c440f2e69c0a0db888a670a34.tar.gz
Kamon-01a34f67ff75419c440f2e69c0a0db888a670a34.tar.bz2
Kamon-01a34f67ff75419c440f2e69c0a0db888a670a34.zip
! all: improve the metric recorders infrastructure
Diffstat (limited to 'kamon-akka-remote/src/test/scala/kamon')
-rw-r--r--kamon-akka-remote/src/test/scala/kamon/akka/instrumentation/RemotingInstrumentationSpec.scala (renamed from kamon-akka-remote/src/test/scala/kamon/instrumentation/akka/RemotingInstrumentationSpec.scala)26
1 files changed, 16 insertions, 10 deletions
diff --git a/kamon-akka-remote/src/test/scala/kamon/instrumentation/akka/RemotingInstrumentationSpec.scala b/kamon-akka-remote/src/test/scala/kamon/akka/instrumentation/RemotingInstrumentationSpec.scala
index 8a3973ca..367a7349 100644
--- a/kamon-akka-remote/src/test/scala/kamon/instrumentation/akka/RemotingInstrumentationSpec.scala
+++ b/kamon-akka-remote/src/test/scala/kamon/akka/instrumentation/RemotingInstrumentationSpec.scala
@@ -8,7 +8,8 @@ import akka.routing.RoundRobinGroup
import akka.testkit.{ ImplicitSender, TestKitBase }
import akka.util.Timeout
import com.typesafe.config.ConfigFactory
-import kamon.trace.TraceRecorder
+import kamon.Kamon
+import kamon.trace.TraceContext
import org.scalatest.{ Matchers, WordSpecLike }
import scala.concurrent.duration._
@@ -18,6 +19,8 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
implicit lazy val system: ActorSystem = ActorSystem("remoting-spec-local-system", ConfigFactory.parseString(
"""
|akka {
+ | loggers = ["akka.event.slf4j.Slf4jLogger"]
+ |
| actor {
| provider = "akka.remote.RemoteActorRefProvider"
| }
@@ -34,6 +37,8 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString(
"""
|akka {
+ | loggers = ["akka.event.slf4j.Slf4jLogger"]
+ |
| actor {
| provider = "akka.remote.RemoteActorRefProvider"
| }
@@ -47,11 +52,13 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
|}
""".stripMargin))
+ lazy val kamon = Kamon(system)
val RemoteSystemAddress = AddressFromURIString("akka.tcp://remoting-spec-remote-system@127.0.0.1:2553")
+ import kamon.tracer.newContext
"The Remoting instrumentation" should {
"propagate the TraceContext when creating a new remote actor" in {
- TraceRecorder.withNewTraceContext("deploy-remote-actor", Some("deploy-remote-actor-1")) {
+ TraceContext.withContext(newContext("deploy-remote-actor", "deploy-remote-actor-1")) {
system.actorOf(TraceTokenReplier.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture")
}
@@ -61,7 +68,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
"propagate the TraceContext when sending a message to a remotely deployed actor" in {
val remoteRef = system.actorOf(TraceTokenReplier.remoteProps(None, RemoteSystemAddress), "remote-message-fixture")
- TraceRecorder.withNewTraceContext("message-remote-actor", Some("message-remote-actor-1")) {
+ TraceContext.withContext(newContext("message-remote-actor", "message-remote-actor-1")) {
remoteRef ! "reply-trace-token"
}
@@ -73,7 +80,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
implicit val askTimeout = Timeout(10 seconds)
val remoteRef = system.actorOf(TraceTokenReplier.remoteProps(None, RemoteSystemAddress), "remote-ask-and-pipe-fixture")
- TraceRecorder.withNewTraceContext("ask-and-pipe-remote-actor", Some("ask-and-pipe-remote-actor-1")) {
+ TraceContext.withContext(newContext("ask-and-pipe-remote-actor", "ask-and-pipe-remote-actor-1")) {
(remoteRef ? "reply-trace-token") pipeTo (testActor)
}
@@ -85,7 +92,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
remoteSystem.actorOf(TraceTokenReplier.props(None), "actor-selection-target-b")
val selection = system.actorSelection(RemoteSystemAddress + "/user/actor-selection-target-*")
- TraceRecorder.withNewTraceContext("message-remote-actor-selection", Some("message-remote-actor-selection-1")) {
+ TraceContext.withContext(newContext("message-remote-actor-selection", "message-remote-actor-selection-1")) {
selection ! "reply-trace-token"
}
@@ -97,7 +104,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
"propagate the TraceContext a remotely supervised child fails" in {
val supervisor = system.actorOf(Props(new SupervisorOfRemote(testActor, RemoteSystemAddress)))
- TraceRecorder.withNewTraceContext("remote-supervision", Some("remote-supervision-1")) {
+ TraceContext.withContext(newContext("remote-supervision", "remote-supervision-1")) {
supervisor ! "fail"
}
@@ -108,7 +115,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat
remoteSystem.actorOf(TraceTokenReplier.props(None), "remote-routee")
val router = system.actorOf(RoundRobinGroup(List(RemoteSystemAddress + "/user/actor-selection-target-*")).props(), "router")
- TraceRecorder.withNewTraceContext("remote-routee", Some("remote-routee-1")) {
+ TraceContext.withContext(newContext("remote-routee", "remote-routee-1")) {
router ! "reply-trace-token"
}
@@ -127,12 +134,11 @@ class TraceTokenReplier(creationTraceContextListener: Option[ActorRef]) extends
case "fail" ⇒
throw new ArithmeticException("Division by zero.")
case "reply-trace-token" ⇒
- log.info("Sending back the TT: " + TraceRecorder.currentContext.token)
sender ! currentTraceContextInfo
}
def currentTraceContextInfo: String = {
- val ctx = TraceRecorder.currentContext
+ val ctx = TraceContext.currentContext
s"name=${ctx.name}|token=${ctx.token}|isOpen=${ctx.isOpen}"
}
}
@@ -161,7 +167,7 @@ class SupervisorOfRemote(traceContextListener: ActorRef, remoteAddress: Address)
}
def currentTraceContextInfo: String = {
- val ctx = TraceRecorder.currentContext
+ val ctx = TraceContext.currentContext
s"name=${ctx.name}|token=${ctx.token}|isOpen=${ctx.isOpen}"
}
}