diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-14 13:50:36 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-14 13:50:36 +0100 |
commit | e931727454fbd97fb39d163255edbcdcd7bcdbc6 (patch) | |
tree | 98b4bdcaa1af1dbbf201036ce05021bc096db62f /kamon-akka-remote/src/test/scala/kamon | |
parent | 8af0dfb1e2c8892023dd1bc6fbae1dae2ffb16ba (diff) | |
parent | 66b35556aa1bf0975cefa35603660991cdfcc526 (diff) | |
download | Kamon-e931727454fbd97fb39d163255edbcdcd7bcdbc6.tar.gz Kamon-e931727454fbd97fb39d163255edbcdcd7bcdbc6.tar.bz2 Kamon-e931727454fbd97fb39d163255edbcdcd7bcdbc6.zip |
Merge branch 'single-kamon-instance-per-jvm' into release-legacy-akka-2.2
Conflicts:
kamon-akka-remote/src/test/scala/kamon/akka/instrumentation/RemotingInstrumentationSpec.scala
kamon-core/src/main/scala/kamon/instrumentation/akka/ActorCellInstrumentation.scala
kamon-core/src/main/scala/kamon/instrumentation/akka/AskPatternInstrumentation.scala
kamon-core/src/main/scala/kamon/metric/MetricsExtension.scala
kamon-core/src/main/scala/kamon/metric/Subscriptions.scala
kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala
kamon-core/src/main/scala/kamon/metric/instrument/MinMaxCounter.scala
kamon-core/src/test/scala/kamon/instrumentation/akka/ActorCellInstrumentationSpec.scala
kamon-core/src/test/scala/kamon/metric/ActorMetricsSpec.scala
kamon-core/src/test/scala/kamon/metric/RouterMetricsSpec.scala
kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala
kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala
kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala
kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala
kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala
kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala
kamon-newrelic/src/main/scala/kamon/newrelic/Agent.scala
kamon-newrelic/src/main/scala/kamon/newrelic/MetricReporter.scala
kamon-play/src/main/scala/kamon/play/Play.scala
kamon-play/src/main/scala/kamon/play/action/KamonTraceActions.scala
kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala
kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala
kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala
project/Dependencies.scala
version.sbt
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) | 60 |
1 files changed, 34 insertions, 26 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 63cc9832..e0aa90ac 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.RoundRobinRouter 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._ @@ -17,25 +18,32 @@ import scala.util.control.NonFatal class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Matchers { implicit def self = testActor - implicit lazy val system: ActorSystem = ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( - """ - |akka { - | actor { - | provider = "akka.remote.RemoteActorRefProvider" - | } - | remote { - | enabled-transports = ["akka.remote.netty.tcp"] - | netty.tcp { - | hostname = "127.0.0.1" - | port = 2552 - | } - | } - |} - """.stripMargin)) + implicit lazy val system: ActorSystem = { + Kamon.start() + ActorSystem("remoting-spec-local-system", ConfigFactory.parseString( + """ + |akka { + | loggers = ["akka.event.slf4j.Slf4jLogger"] + | + | actor { + | provider = "akka.remote.RemoteActorRefProvider" + | } + | remote { + | enabled-transports = ["akka.remote.netty.tcp"] + | netty.tcp { + | hostname = "127.0.0.1" + | port = 2552 + | } + | } + |} + """.stripMargin)) + } val remoteSystem: ActorSystem = ActorSystem("remoting-spec-remote-system", ConfigFactory.parseString( """ |akka { + | loggers = ["akka.event.slf4j.Slf4jLogger"] + | | actor { | provider = "akka.remote.RemoteActorRefProvider" | } @@ -50,10 +58,11 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat """.stripMargin)) val RemoteSystemAddress = AddressFromURIString("akka.tcp://remoting-spec-remote-system@127.0.0.1:2553") + import Kamon.tracer "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(tracer.newContext("deploy-remote-actor", "deploy-remote-actor-1")) { system.actorOf(TraceTokenReplier.remoteProps(Some(testActor), RemoteSystemAddress), "remote-deploy-fixture") } @@ -63,7 +72,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(tracer.newContext("message-remote-actor", "message-remote-actor-1")) { remoteRef ! "reply-trace-token" } @@ -75,7 +84,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(tracer.newContext("ask-and-pipe-remote-actor", "ask-and-pipe-remote-actor-1")) { (remoteRef ? "reply-trace-token") pipeTo (testActor) } @@ -87,7 +96,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(tracer.newContext("message-remote-actor-selection", "message-remote-actor-selection-1")) { selection ! "reply-trace-token" } @@ -96,10 +105,10 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat expectMsg("name=message-remote-actor-selection|token=message-remote-actor-selection-1|isOpen=true") } - "propagate the TraceContext a remotely supervised child fails" in { + "propagate the TraceContext if 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(tracer.newContext("remote-supervision", "remote-supervision-1")) { supervisor ! "fail" } @@ -111,7 +120,7 @@ class RemotingInstrumentationSpec extends TestKitBase with WordSpecLike with Mat val routees = Vector[String](RemoteSystemAddress + "/user/remote-routee") val router = system.actorOf(Props.empty.withRouter(RoundRobinRouter(routees = routees))) - TraceRecorder.withNewTraceContext("remote-routee", Some("remote-routee-1")) { + TraceContext.withContext(tracer.newContext("remote-routee", "remote-routee-1")) { router ! "reply-trace-token" } @@ -130,12 +139,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}" } } @@ -164,7 +172,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}" } } |