Skip to content

Commit

Permalink
fix kamon repo definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Topolnak committed Dec 23, 2013
1 parent f2a4fcd commit f648ccc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package akka.actor

import org.aspectj.lang.annotation._
import kamon.trace.{Trace, ContextAware}
import kamon.trace.{ Trace, ContextAware }
import akka.dispatch.sysmsg.EarliestFirstSystemMessageList
import org.aspectj.lang.ProceedingJoinPoint

Expand Down Expand Up @@ -56,7 +56,7 @@ class ActorSystemMessagePassingTracing {

@Around("systemMessageProcessing(messages)")
def aroundSystemMessageInvoke(pjp: ProceedingJoinPoint, messages: EarliestFirstSystemMessageList): Any = {
if(messages.nonEmpty) {
if (messages.nonEmpty) {
val ctx = messages.head.asInstanceOf[ContextAware].traceContext
Trace.withContext(ctx)(pjp.proceed())

Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
package kamon.trace.instrumentation

import akka.testkit.{ImplicitSender, TestKit}
import akka.testkit.{ ImplicitSender, TestKit }
import akka.actor._
import org.scalatest.WordSpecLike
import kamon.trace.Trace
import scala.util.control.NonFatal
import akka.actor.SupervisorStrategy.{Escalate, Stop, Restart, Resume}
import akka.actor.SupervisorStrategy.{ Escalate, Stop, Restart, Resume }
import scala.concurrent.duration._

class ActorSystemMessagePassingInstrumentationSpec extends TestKit(ActorSystem("actor-message-passing-tracing-spec")) with WordSpecLike with ImplicitSender {
implicit val executionContext = system.dispatcher


"the system message passing instrumentation" should {
"keep the TraceContext while processing the Create message in top level actors" in new TraceContextFixture {
Trace.withContext(testTraceContext) {
system.actorOf(Props(new Actor {

testActor ! Trace.context()

def receive: Actor.Receive = { case any => }
def receive: Actor.Receive = { case any }
}))
}

expectMsg(testTraceContext)
}


"keep the TraceContext while processing the Create message in non top level actors" in new TraceContextFixture {
Trace.withContext(testTraceContext) {
system.actorOf(Props(new Actor {
def receive: Actor.Receive = {
case any =>
case any
context.actorOf(Props(new Actor {

testActor ! Trace.context()

def receive: Actor.Receive = { case any => }
def receive: Actor.Receive = { case any }
}))
}
})) ! "any"
Expand All @@ -45,7 +43,6 @@ class ActorSystemMessagePassingInstrumentationSpec extends TestKit(ActorSystem("
expectMsg(testTraceContext)
}


"keep the TraceContext in the supervision cycle" when {
"the actor is resumed" in new TraceContextFixture {
val supervisor = supervisorWithDirective(Resume)
Expand Down Expand Up @@ -106,59 +103,59 @@ class ActorSystemMessagePassingInstrumentationSpec extends TestKit(ActorSystem("
}

def supervisorWithDirective(directive: SupervisorStrategy.Directive, sendPreRestart: Boolean = false, sendPostRestart: Boolean = false,
sendPostStop: Boolean = false, sendPreStart: Boolean = false): ActorRef = {
sendPostStop: Boolean = false, sendPreStart: Boolean = false): ActorRef = {
class GrandParent extends Actor {
val child = context.actorOf(Props(new Parent))

override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() {
case NonFatal(throwable) => testActor ! Trace.context(); Stop
case NonFatal(throwable) testActor ! Trace.context(); Stop
}

def receive = {
case any => child forward any
case any child forward any
}
}

class Parent extends Actor {
val child = context.actorOf(Props(new Child))

override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() {
case NonFatal(throwable) => testActor ! Trace.context(); directive
case NonFatal(throwable) testActor ! Trace.context(); directive
}

def receive: Actor.Receive = {
case any => child forward any
case any child forward any
}

override def postStop(): Unit = {
if(sendPostStop) testActor ! Trace.context()
if (sendPostStop) testActor ! Trace.context()
super.postStop()
}
}

class Child extends Actor {
def receive = {
case "fail" => 1/0
case "context" => sender ! Trace.context()
case "fail" 1 / 0
case "context" sender ! Trace.context()
}

override def preRestart(reason: Throwable, message: Option[Any]): Unit = {
if(sendPreRestart) testActor ! Trace.context()
if (sendPreRestart) testActor ! Trace.context()
super.preRestart(reason, message)
}

override def postRestart(reason: Throwable): Unit = {
if(sendPostRestart) testActor ! Trace.context()
if (sendPostRestart) testActor ! Trace.context()
super.postRestart(reason)
}

override def postStop(): Unit = {
if(sendPostStop) testActor ! Trace.context()
if (sendPostStop) testActor ! Trace.context()
super.postStop()
}

override def preStart(): Unit = {
if(sendPreStart) testActor ! Trace.context()
if (sendPreStart) testActor ! Trace.context()
super.preStart()
}
}
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

resolvers += Resolver.url("Kamon Releases", url("http://repo.kamon.io"))(Resolver.ivyStylePatterns)
resolvers += "Kamon Releases" at "http://repo.kamon.io"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")

Expand Down

0 comments on commit f648ccc

Please sign in to comment.