aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/kamon/executor/eventbus.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/kamon/executor/eventbus.scala')
-rw-r--r--src/main/scala/kamon/executor/eventbus.scala40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/main/scala/kamon/executor/eventbus.scala b/src/main/scala/kamon/executor/eventbus.scala
index ebaff7eb..ed76334f 100644
--- a/src/main/scala/kamon/executor/eventbus.scala
+++ b/src/main/scala/kamon/executor/eventbus.scala
@@ -5,7 +5,7 @@ import akka.event.LookupClassification
import akka.actor._
import java.util.concurrent.TimeUnit
-import kamon.{TraceContext}
+import kamon.{CodeBlockExecutionTime, Kamon, TraceContext}
import akka.util.Timeout
import scala.util.Success
import scala.util.Failure
@@ -41,7 +41,7 @@ class PingActor(val target: ActorRef) extends Actor with ActorLogging {
def receive = {
case Pong() => {
- log.info(s"pong with context ${TraceContext.current}")
+ log.info(s"pong with context ${Kamon.context}")
Thread.sleep(1000)
sender ! Ping()
}
@@ -57,7 +57,7 @@ class PongActor extends Actor with ActorLogging {
case Ping() => {
Thread.sleep(3000)
sender ! Pong()
- log.info(s"ping with context ${TraceContext.current}")
+ log.info(s"ping with context ${Kamon.context}")
}
case a: Any => println(s"Got ${a} in PONG")
}
@@ -78,7 +78,7 @@ object TryAkka extends App{
- def threadPrintln(body: String) = println(s"[${Thread.currentThread().getName}] - [${TraceContext.current}] : $body")
+ def threadPrintln(body: String) = println(s"[${Thread.currentThread().getName}] - [${Kamon.context}] : $body")
/*
val newRelicReporter = new NewRelicReporter(registry)
@@ -88,32 +88,20 @@ object TryAkka extends App{
import akka.pattern.ask
implicit val timeout = Timeout(10, TimeUnit.SECONDS)
implicit def execContext = system.dispatcher
- //for(i <- 1 to 8) {
-/* val i = 1
- TraceContext.start
- val ping = system.actorOf(Props(new PingActor(system.actorOf(Props[PongActor], s"ping-${i}"))), s"pong-${i}")
- val f = ping ? Pong()
-
- f.map({
- a => threadPrintln(s"In the map body, with the context: ${TraceContext.current}")
- })
- .flatMap({
- (a: Any) => {
- threadPrintln(s"Executing the flatMap, with the context: ${TraceContext.current}")
- Future { s"In the flatMap body, with the context: ${TraceContext.current}" }
- }
- })
- .onComplete({
- case Success(p) => threadPrintln(s"On my main success, with String [$p] and the context: ${TraceContext.current}")
- case Failure(t) => threadPrintln(s"Something went wrong in the main, with the context: ${TraceContext.current}")
- })*/
- //}
-
- TraceContext.start
+
+
+
+ Kamon.start
+
+ Kamon.context.get.append(CodeBlockExecutionTime("some-block", System.nanoTime(), System.nanoTime()))
threadPrintln("Before doing it")
val f = Future { threadPrintln("This is happening inside the future body") }
+ Kamon.stop
+
+ Thread.sleep(3000)
+ system.shutdown()
/* appActorEventBus.subscribe(subscriber, NEW_POST_CHANNEL)
appActorEventBus.publish(MessageEvent(NEW_POST_CHANNEL,PostMessage(text="hello world")))*/