aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala
blob: 15e967f2c3d7eb2ee91adb196c816e8d206106f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package akka.instrumentation

import org.scalatest.WordSpec
import org.scalatest.matchers.{ShouldMatchers, MustMatchers}
import akka.actor.{Actor, Props, ActorSystem}
import kamon.metric.Metrics._
import scala.collection.JavaConverters._
import akka.testkit.TestActorRef


class ActorInstrumentationSpec extends WordSpec with MustMatchers with ShouldMatchers {
  implicit val system = ActorSystem()
  import system._

  val echoRef = actorOf(Props(new EchoActor), "Echo-Actor")
  val meterForEchoActor = "meter-for-akka://default/user/Echo-Actor"
  val totalMessages = 1000

  "an instrumented Actor" should  {
    "send a message and record a metric on the Metrics Registry with the number of sent messages" in {

      val echoActor = TestActorRef[EchoActor]



      (1 to totalMessages).foreach {x:Int =>
        echoActor ! s"Message ${x}"
      }

      println("After all")
      //val messages = registry.getMeters.asScala.get(meterForEchoActor).get.getCount

      //messages should equal(totalMessages)
    }
  }

}

class EchoActor extends Actor {
  def receive = {
    case msg  println("SOME"); sender ! msg
  }
}