aboutsummaryrefslogtreecommitdiff
path: root/kamon-playground
diff options
context:
space:
mode:
authorIvan Topolnak <ivantopo@gmail.com>2013-11-05 18:38:39 -0300
committerIvan Topolnak <ivantopo@gmail.com>2013-11-05 18:38:39 -0300
commit2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1 (patch)
tree56c4ad1f025c9144376cd4463ad4d4a23e37b571 /kamon-playground
parent5127c3bb83cd6fe90e071720d995cfb53d913e6a (diff)
downloadKamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.tar.gz
Kamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.tar.bz2
Kamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.zip
basic separation of concerns between sub-projects
Diffstat (limited to 'kamon-playground')
-rw-r--r--kamon-playground/src/main/resources/logback.xml12
-rw-r--r--kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala101
2 files changed, 113 insertions, 0 deletions
diff --git a/kamon-playground/src/main/resources/logback.xml b/kamon-playground/src/main/resources/logback.xml
new file mode 100644
index 00000000..2ae1e3bd
--- /dev/null
+++ b/kamon-playground/src/main/resources/logback.xml
@@ -0,0 +1,12 @@
+<configuration scan="true">
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date{HH:mm:ss.SSS} %-5level [%X{uow}][%X{requestId}] [%thread] %logger{55} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
diff --git a/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala
new file mode 100644
index 00000000..7ee92580
--- /dev/null
+++ b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala
@@ -0,0 +1,101 @@
+package test
+
+import akka.actor._
+import spray.routing.SimpleRoutingApp
+import akka.util.Timeout
+import spray.httpx.RequestBuilding
+import scala.concurrent.{Await, Future}
+import kamon.spray.UowDirectives
+import kamon.trace.Trace
+
+object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuilding with UowDirectives {
+ import scala.concurrent.duration._
+ import spray.client.pipelining._
+ import akka.pattern.ask
+
+ implicit val system = ActorSystem("test")
+ import system.dispatcher
+
+ val act = system.actorOf(Props(new Actor {
+ def receive: Actor.Receive = { case any => sender ! any }
+ }), "com.despegar-2:[]s-w@&,*")
+
+ implicit val timeout = Timeout(30 seconds)
+
+ val pipeline = sendReceive
+ val replier = system.actorOf(Props[Replier])
+
+ startServer(interface = "localhost", port = 9090) {
+ get {
+ path("test"){
+ uow {
+ complete {
+ val futures = pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: pipeline(Get("http://10.254.209.14:8000/")).map(r => "Ok") :: Nil
+
+ Future.sequence(futures).map(l => "Ok")
+ }
+ }
+ } ~
+ path("reply" / Segment) { reqID =>
+ uow {
+ complete {
+ if (Trace.context().isEmpty)
+ println("ROUTE NO CONTEXT")
+
+ (replier ? reqID).mapTo[String]
+ }
+ }
+ } ~
+ path("ok") {
+ complete("ok")
+ } ~
+ path("future") {
+ dynamic {
+ complete(Future { "OK" })
+ }
+ } ~
+ path("error") {
+ complete {
+ throw new NullPointerException
+ "okk"
+ }
+ }
+ }
+ }
+
+}
+
+object Verifier extends App {
+
+ def go: Unit = {
+ import scala.concurrent.duration._
+ import spray.client.pipelining._
+
+ implicit val system = ActorSystem("test")
+ import system.dispatcher
+
+ 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))
+ }
+
+
+
+
+}
+
+class Replier extends Actor with ActorLogging {
+ def receive = {
+ case anything =>
+ if(Trace.context.isEmpty)
+ log.warning("PROCESSING A MESSAGE WITHOUT CONTEXT")
+
+ log.info("Processing at the Replier")
+ sender ! anything
+ }
+}