diff options
author | Diego Parra <dparra@despegar.com> | 2013-05-31 19:50:16 -0300 |
---|---|---|
committer | Diego Parra <dparra@despegar.com> | 2013-05-31 19:50:16 -0300 |
commit | 8f4c649e6082671c416b250589540005d9fe1bf8 (patch) | |
tree | ad5fb52d871c8b66b634379f434818e86af6bd7e /src/test/scala/akka | |
parent | 0609c571e2c390f4b069db3f0b1808947d27154d (diff) | |
download | Kamon-8f4c649e6082671c416b250589540005d9fe1bf8.tar.gz Kamon-8f4c649e6082671c416b250589540005d9fe1bf8.tar.bz2 Kamon-8f4c649e6082671c416b250589540005d9fe1bf8.zip |
WIP: Metrics 3
Diffstat (limited to 'src/test/scala/akka')
-rw-r--r-- | src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala b/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala index 2921824e..4cc15a2f 100644 --- a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala +++ b/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala @@ -3,31 +3,31 @@ package akka.instrumentation import org.scalatest.WordSpec import org.scalatest.matchers.{ShouldMatchers, MustMatchers} import akka.actor.{Actor, Props, ActorSystem} -import kamon.metric.Metrics -import com.codahale.metrics.Meter +import kamon.metric.Metrics._ import scala.collection.JavaConverters._ class ActorInstrumentationSpec extends WordSpec with MustMatchers with ShouldMatchers { - import Metrics.metricsRegistry._ 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 { - "a instrumented Actor" should { - "send a message and record a metric on the Metrics Registry and count messages" in { + (1 to totalMessages).foreach {x:Int => + echoRef ! s"Message ${x}" + } - echoRef ! "Message 1" - echoRef ! "Message 2" - echoRef ! "Message 3" - echoRef ! "Message 4" - echoRef ! "Message 5" - echoRef ! "Message 6" + //to ensure that all messages was received + Thread.sleep(1000) - val meter = getMeters.asScala.filterKeys(_.toLowerCase.contains("Echo-Actor".toLowerCase())).collectFirst{case pair:(String, Meter) => pair._2.getCount}.get + val messages = metricsRegistry.getMeters.asScala.get(meterForEchoActor).get.getCount - meter should equal(6) + messages should equal(totalMessages) } } |