aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/instrumentation/DispatcherInstrumentationSpec.scala
blob: 89ef61f397ad627fe4b86855439f3fbf00483f96 (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
package kamon.instrumentation

import org.scalatest.{Matchers, WordSpec}
import akka.actor.{Actor, Props, ActorSystem}
import kamon.metric.MetricDirectory
import kamon.Kamon

class DispatcherInstrumentationSpec extends WordSpec with Matchers{


  "the dispatcher instrumentation" should {
    "instrument a dispatcher that belongs to a non-filtered actor system" in new SingleDispatcherActorSystem {
      val x = Kamon.Metric.actorSystem("single-dispatcher").get.dispatchers
      (1 to 10).foreach(actor ! _)

      val active = x.get("akka.actor.default-dispatcher").get.activeThreadCount.snapshot
      println("Active max: "+active.max)
      println("Active min: "+active.min)

    }
  }


  trait SingleDispatcherActorSystem {
    val actorSystem = ActorSystem("single-dispatcher")
    val actor = actorSystem.actorOf(Props(new Actor {
      def receive = {
        case a => sender ! a;
      }
    }))

  }
}