diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2013-10-02 09:03:42 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2013-10-02 09:03:42 -0300 |
commit | e2a9aa15b6ecda441fd81960b31b0b836af6d64a (patch) | |
tree | 3cee425fdf5fe7a1ffb4b85212e0bc8d3e75ffd0 /kamon-core/src | |
parent | 65428c248502dadb2bdefa58cbc034ced6af9354 (diff) | |
download | Kamon-e2a9aa15b6ecda441fd81960b31b0b836af6d64a.tar.gz Kamon-e2a9aa15b6ecda441fd81960b31b0b836af6d64a.tar.bz2 Kamon-e2a9aa15b6ecda441fd81960b31b0b836af6d64a.zip |
wip
Diffstat (limited to 'kamon-core/src')
5 files changed, 40 insertions, 23 deletions
diff --git a/kamon-core/src/main/scala/kamon/TraceContext.scala b/kamon-core/src/main/scala/kamon/TraceContext.scala index 4ad533fd..0dfc1630 100644 --- a/kamon-core/src/main/scala/kamon/TraceContext.scala +++ b/kamon-core/src/main/scala/kamon/TraceContext.scala @@ -22,10 +22,11 @@ object TraceContext { val traceIdCounter = new AtomicLong def apply()(implicit system: ActorSystem) = { - val actor = system.actorOf(UowTraceAggregator.props(reporter, 5 seconds), s"tracer-${traceIdCounter.incrementAndGet()}") + val n = traceIdCounter.incrementAndGet() + val actor = system.actorOf(UowTraceAggregator.props(reporter, 5 seconds), s"tracer-${n}") actor ! Start() - new TraceContext(100, actor) // TODO: Move to a kamon specific supervisor, like /user/kamon/tracer + new TraceContext(n, actor) // TODO: Move to a kamon specific supervisor, like /user/kamon/tracer } } diff --git a/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala index 393293f1..bff118d9 100644 --- a/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala +++ b/kamon-core/src/main/scala/kamon/instrumentation/RunnableInstrumentation.scala @@ -58,8 +58,8 @@ class RunnableInstrumentation { @Around("runnableExecution()") def around(pjp: ProceedingJoinPoint) = { import pjp._ - /*if(traceContext.isEmpty) - println("OOHHH NOOOOO")*/ + if(traceContext.isEmpty) + println("NOMONEY") withContext(traceContext, proceed()) } diff --git a/kamon-core/src/main/scala/kamon/instrumentation/SprayServerInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/SprayServerInstrumentation.scala index 0299c4c5..06254739 100644 --- a/kamon-core/src/main/scala/kamon/instrumentation/SprayServerInstrumentation.scala +++ b/kamon-core/src/main/scala/kamon/instrumentation/SprayServerInstrumentation.scala @@ -32,20 +32,32 @@ class SprayServerInstrumentation { //@After("openRequestInit()") //def afterInit(): Unit = { Tracer.start + val discard = openRequest.asInstanceOf[ContextAware].traceContext + + //println("Reply: %s - %s ", Tracer.context().get.id, request.uri.path.toString()) + +// if(discard.isEmpty || discard != Tracer.context()) { +// println("MEGA ERROR") +// } //openRequest.traceContext //println("Created the context: " + Tracer.context() + " for the transaction: " + request) Tracer.context().map(_.entries ! Rename(request.uri.path.toString())) } - @Pointcut("execution(* spray.can.server.OpenRequestComponent$DefaultOpenRequest.handleResponseEndAndReturnNextOpenRequest(..))") - def openRequestCreation(): Unit = {} + @Pointcut("execution(* spray.can.server.OpenRequestComponent$DefaultOpenRequest.handleResponseEndAndReturnNextOpenRequest(..)) && target(openRequest)") + def openRequestCreation(openRequest: OpenRequest): Unit = {} - @After("openRequestCreation()") - def afterFinishingRequest(): Unit = { + @After("openRequestCreation(openRequest)") + def afterFinishingRequest(openRequest: OpenRequest): Unit = { // println("Finishing a request: " + Tracer.context()) - + val original = openRequest.asInstanceOf[ContextAware].traceContext + println("The original is: " + original + " - " + openRequest.request.uri.path) Tracer.context().map(_.entries ! Finish()) + if(Tracer.context() != original) { + println(s"OMG DIFFERENT Original: [${original}] - Came in: [${Tracer.context}]") + } + if(Tracer.context().isEmpty) { println("WOOOOOPAAAAAAAAA") } diff --git a/kamon-core/src/main/scala/test/PingPong.scala b/kamon-core/src/main/scala/test/PingPong.scala index 6d8c4636..8808e4bf 100644 --- a/kamon-core/src/main/scala/test/PingPong.scala +++ b/kamon-core/src/main/scala/test/PingPong.scala @@ -93,22 +93,26 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil } -object Verifier extends App with RequestBuilding { - import scala.concurrent.duration._ - import spray.client.pipelining._ - import akka.pattern.ask +object Verifier extends App { - implicit val system = ActorSystem("test") - import system.dispatcher + def go: Unit = { + import scala.concurrent.duration._ + import spray.client.pipelining._ + import akka.pattern.ask - implicit val timeout = Timeout(30 seconds) + implicit val system = ActorSystem("test") + import system.dispatcher - val pipeline = sendReceive + implicit val timeout = Timeout(30 seconds) + + val pipeline = sendReceive + + val futures = Future.sequence(for(i <- 1 to 500) yield { + pipeline(Get("http://127.0.0.1:9090/reply/"+i)).map(r => r.entity.asString == i.toString) + }) + println("Everything is: "+ Await.result(futures, 10 seconds).forall(a => a == true)) + } - val futures = Future.sequence(for(i <- 1 to 500) yield { - pipeline(Get("http://127.0.0.1/reply/"+i)).map(r => r.entity.asString == i.toString) - }) - Await.result(futures, 10 seconds).forall(_) diff --git a/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala b/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala index fe89695b..86bef0d8 100644 --- a/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala +++ b/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala @@ -25,7 +25,7 @@ class RunnableInstrumentationSpec extends WordSpec with Matchers with ScalaFutur "should be available during the execution of onComplete callbacks" in { new FutureWithContextFixture { val onCompleteContext = Promise[TraceContext]() - + Tracer.clear futureWithContext.onComplete({ case _ => onCompleteContext.complete(Success(Tracer.context.get)) }) @@ -70,7 +70,7 @@ class RunnableInstrumentationSpec extends WordSpec with Matchers with ScalaFutur val testContext = TraceContext() Tracer.set(testContext) - val futureWithContext = Future { Tracer.context} + val futureWithContext = Future { Tracer.context } } trait FutureWithoutContextFixture { |