Skip to content

Commit

Permalink
= kamon-pekko: Fix compile-errors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TjarkoG committed Nov 7, 2023
1 parent e18c871 commit ffb77be
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 758 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ import akka.routing._
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import kamon.Kamon
import kamon.testkit.{InitAndStopKamonAfterAll, MetricInspection}
import kamon.tag.Lookups._
import kamon.testkit.{InitAndStopKamonAfterAll, MetricInspection}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.Eventually
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

import scala.collection.mutable.ListBuffer
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._


class ActorCellInstrumentationSpec extends TestKit(ActorSystem("ActorCellInstrumentationSpec")) with AnyWordSpecLike
with BeforeAndAfterAll with ImplicitSender with Eventually with MetricInspection.Syntax with Matchers with InitAndStopKamonAfterAll {
implicit lazy val executionContext = system.dispatcher
implicit lazy val executionContext: ExecutionContext = system.dispatcher
import ContextTesting._

"the message passing instrumentation" should {
Expand All @@ -59,7 +60,7 @@ class ActorCellInstrumentationSpec extends TestKit(ActorSystem("ActorCellInstrum
}

"propagate the current context when using the ask pattern" in new EchoActorFixture {
implicit val timeout = Timeout(1 seconds)
implicit val timeout: Timeout = Timeout(1 seconds)
Kamon.runWithContext(testContext("propagate-with-ask")) {
// The pipe pattern use Futures internally, so FutureTracing test should cover the underpinnings of it.
(contextEchoActor ? "test") pipeTo (testActor)
Expand Down Expand Up @@ -122,11 +123,11 @@ class ActorCellInstrumentationSpec extends TestKit(ActorSystem("ActorCellInstrum
}

trait EchoActorFixture {
val contextEchoActor = system.actorOf(Props[ContextStringEcho])
val contextEchoActor: ActorRef = system.actorOf(Props[ContextStringEcho])
}

trait EchoSimpleRouterFixture {
val router = {
val router: Router = {
val routees = Vector.fill(5) {
val r = system.actorOf(Props[ContextStringEcho])
ActorRefRoutee(r)
Expand All @@ -136,22 +137,22 @@ class ActorCellInstrumentationSpec extends TestKit(ActorSystem("ActorCellInstrum
}

trait EchoPoolRouterFixture {
val pool = system.actorOf(RoundRobinPool(nrOfInstances = 5).props(Props[ContextStringEcho]), "pool-router")
val pool: ActorRef = system.actorOf(RoundRobinPool(nrOfInstances = 5).props(Props[ContextStringEcho]), "pool-router")
}

trait EchoGroupRouterFixture {
val routees = Vector.fill(5) {
val routees: Vector[ActorRef] = Vector.fill(5) {
system.actorOf(Props[ContextStringEcho])
}

val group = system.actorOf(RoundRobinGroup(routees.map(_.path.toStringWithoutAddress)).props(), "group-router")
val group: ActorRef = system.actorOf(RoundRobinGroup(routees.map(_.path.toStringWithoutAddress)).props(), "group-router")
}
}

class ContextStringEcho extends Actor {
import ContextTesting._

def receive = {
def receive: Receive = {
case _: String =>
sender ! Kamon.currentContext().getTag(plain(TestKey))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import kamon.instrumentation.akka.ContextTesting._
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.duration._

class AskPatternInstrumentationSpec extends TestKit(ActorSystem("AskPatternInstrumentationSpec")) with AnyWordSpecLike
with InitAndStopKamonAfterAll with ImplicitSender {

implicit lazy val ec = system.dispatcher
implicit val askTimeout = Timeout(10 millis)
implicit lazy val ec: ExecutionContextExecutor = system.dispatcher
implicit val askTimeout: Timeout = Timeout(10 millis)

// TODO: Make this work with ActorSelections

Expand Down Expand Up @@ -93,7 +94,7 @@ class AskPatternInstrumentationSpec extends TestKit(ActorSystem("AskPatternInstr
}

class NoReply extends Actor {
def receive = {
def receive: Receive = {
case _ =>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class MessageTracingSpec extends TestKit(ActorSystem("MessageTracing")) with Any
}

"not track Akka Streams actors" in {
implicit val timeout = Timeout(10 seconds)
implicit val timeout: Timeout = Timeout(10 seconds)
val actorWithMaterializer = system.actorOf(Props[ActorWithMaterializer])

val finishedStream = Kamon.runWithSpan(Kamon.serverSpanBuilder("wrapper", "test").start()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ class TracingTestActor extends Actor {
}

class ActorWithMaterializer extends Actor {
implicit val mat = ActorMaterializer()
implicit val mat: Materializer = Materializer(context)

override def receive: Receive = {
case "stream" =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import kamon.instrumentation.akka.ContextTesting._
import kamon.tag.Lookups._
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.{AnyWordSpec, AnyWordSpecLike}
import org.scalatest.wordspec.AnyWordSpecLike

import scala.concurrent.ExecutionContext
import scala.util.control.NonFatal

class SystemMessageInstrumentationSpec extends TestKit(ActorSystem("ActorSystemMessageInstrumentationSpec")) with AnyWordSpecLike with Matchers
with BeforeAndAfterAll with ImplicitSender {
implicit lazy val executionContext = system.dispatcher
implicit lazy val executionContext: ExecutionContext = system.dispatcher

"the system message passing instrumentation" should {
"capture and propagate the current context while processing the Create message in top level actors" in {
Expand Down
Loading

0 comments on commit ffb77be

Please sign in to comment.