diff options
Diffstat (limited to 'kamon-akka/src/test/scala')
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala (renamed from kamon-akka/src/test/scala/kamon/metric/ActorMetricsSpec.scala) | 62 | ||||
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala (renamed from kamon-akka/src/test/scala/kamon/metric/DispatcherMetricsSpec.scala) | 116 | ||||
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala (renamed from kamon-akka/src/test/scala/kamon/metric/RouterMetricsSpec.scala) | 49 | ||||
-rw-r--r-- | kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala | 2 |
4 files changed, 115 insertions, 114 deletions
diff --git a/kamon-akka/src/test/scala/kamon/metric/ActorMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala index 322abed2..19a71053 100644 --- a/kamon-akka/src/test/scala/kamon/metric/ActorMetricsSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala @@ -13,42 +13,44 @@ * ========================================================================================= */ -package kamon.metric +package kamon.akka import java.nio.LongBuffer -import kamon.Kamon -import kamon.akka.ActorMetrics -import kamon.metric.ActorMetricsTestActor._ -import kamon.metric.instrument.CollectionContext -import org.scalatest.{ BeforeAndAfterAll, WordSpecLike, Matchers } -import akka.testkit.{ ImplicitSender, TestProbe, TestKitBase } import akka.actor._ +import akka.testkit.TestProbe import com.typesafe.config.ConfigFactory +import kamon.Kamon +import kamon.akka.ActorMetricsTestActor._ +import kamon.metric.EntitySnapshot +import kamon.metric.instrument.CollectionContext +import kamon.testkit.BaseKamonSpec + import scala.concurrent.duration._ -class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender with BeforeAndAfterAll { - implicit lazy val system: ActorSystem = ActorSystem("actor-metrics-spec", ConfigFactory.parseString( - """ - |kamon.metric { - | tick-interval = 1 hour - | default-collection-context-buffer-size = 10 - | - | filters { - | akka-actor { - | includes = [ "user/tracked-*", "user/measuring-*", "user/clean-after-collect", "user/stop" ] - | excludes = [ "user/tracked-explicitly-excluded", "user/non-tracked-actor" ] - | } - | } - | - | instrument-settings { - | akka-actor.mailbox-size.refresh-interval = 1 hour - | } - |} - | - |akka.loglevel = OFF - | - """.stripMargin)) +class ActorMetricsSpec extends BaseKamonSpec("actor-metrics-spec") { + override lazy val config = + ConfigFactory.parseString( + """ + |kamon.metric { + | tick-interval = 1 hour + | default-collection-context-buffer-size = 10 + | + | filters { + | akka-actor { + | includes = [ "user/tracked-*", "user/measuring-*", "user/clean-after-collect", "user/stop" ] + | excludes = [ "user/tracked-explicitly-excluded", "user/non-tracked-actor" ] + | } + | } + | + | instrument-settings { + | akka-actor.mailbox-size.refresh-interval = 1 hour + | } + |} + | + |akka.loglevel = OFF + | + """.stripMargin) "the Kamon actor metrics" should { "respect the configured include and exclude filters" in new ActorMetricsFixtures { @@ -163,7 +165,7 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers with def actorRecorderName(ref: ActorRef): String = ref.path.elements.mkString("/") def actorMetricsRecorderOf(ref: ActorRef): Option[ActorMetrics] = - Kamon(Metrics)(system).register(ActorMetrics, actorRecorderName(ref)).map(_.recorder) + Kamon.metrics.register(ActorMetrics, actorRecorderName(ref)).map(_.recorder) def collectMetricsOf(ref: ActorRef): Option[EntitySnapshot] = { Thread.sleep(5) // Just in case the test advances a bit faster than the actor being tested. diff --git a/kamon-akka/src/test/scala/kamon/metric/DispatcherMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala index 2c530da9..209b5cf5 100644 --- a/kamon-akka/src/test/scala/kamon/metric/DispatcherMetricsSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/DispatcherMetricsSpec.scala @@ -13,72 +13,73 @@ * ========================================================================================= */ -package kamon.metric +package kamon.akka import java.nio.LongBuffer -import akka.actor.{ PoisonPill, Props, ActorRef, ActorSystem } +import akka.actor.{ ActorRef, ActorSystem } import akka.dispatch.MessageDispatcher import akka.testkit.{ TestKitBase, TestProbe } import com.typesafe.config.ConfigFactory import kamon.Kamon -import kamon.akka.{ ForkJoinPoolDispatcherMetrics, ThreadPoolExecutorDispatcherMetrics } -import kamon.metric.ActorMetricsTestActor.{ Pong, Ping } import kamon.metric.instrument.CollectionContext +import kamon.metric.{ EntityRecorder, EntitySnapshot } +import kamon.testkit.BaseKamonSpec import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } -import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ +import scala.concurrent.{ Await, Future } -class DispatcherMetricsSpec extends TestKitBase with WordSpecLike with Matchers with BeforeAndAfterAll { - implicit lazy val system: ActorSystem = ActorSystem("dispatcher-metrics-spec", ConfigFactory.parseString( - """ - |kamon.metric { - | tick-interval = 1 hour - | default-collection-context-buffer-size = 10 - | - | filters = { - | akka-dispatcher { - | includes = [ "*" ] - | excludes = [ "explicitly-excluded" ] - | } - | } - | - | default-instrument-settings { - | gauge.refresh-interval = 1 hour - | min-max-counter.refresh-interval = 1 hour - | } - |} - | - |explicitly-excluded { - | type = "Dispatcher" - | executor = "fork-join-executor" - |} - | - |tracked-fjp { - | type = "Dispatcher" - | executor = "fork-join-executor" - | - | fork-join-executor { - | parallelism-min = 8 - | parallelism-factor = 100.0 - | parallelism-max = 22 - | } - |} - | - |tracked-tpe { - | type = "Dispatcher" - | executor = "thread-pool-executor" - | - | thread-pool-executor { - | core-pool-size-min = 7 - | core-pool-size-factor = 100.0 - | max-pool-size-factor = 100.0 - | max-pool-size-max = 21 - | } - |} - | - """.stripMargin)) +class DispatcherMetricsSpec extends BaseKamonSpec("dispatcher-metrics-spec") { + override lazy val config = + ConfigFactory.parseString( + """ + |kamon.metric { + | tick-interval = 1 hour + | default-collection-context-buffer-size = 10 + | + | filters = { + | akka-dispatcher { + | includes = [ "*" ] + | excludes = [ "explicitly-excluded" ] + | } + | } + | + | default-instrument-settings { + | gauge.refresh-interval = 1 hour + | min-max-counter.refresh-interval = 1 hour + | } + |} + | + |explicitly-excluded { + | type = "Dispatcher" + | executor = "fork-join-executor" + |} + | + |tracked-fjp { + | type = "Dispatcher" + | executor = "fork-join-executor" + | + | fork-join-executor { + | parallelism-min = 8 + | parallelism-factor = 100.0 + | parallelism-max = 22 + | } + |} + | + |tracked-tpe { + | type = "Dispatcher" + | executor = "thread-pool-executor" + | + | thread-pool-executor { + | core-pool-size-min = 7 + | core-pool-size-factor = 100.0 + | max-pool-size-factor = 100.0 + | max-pool-size-max = 21 + | } + |} + | + """.stripMargin) "the Kamon dispatcher metrics" should { "respect the configured include and exclude filters" in { @@ -95,6 +96,7 @@ class DispatcherMetricsSpec extends TestKitBase with WordSpecLike with Matchers "record metrics for a dispatcher with thread-pool-executor" in { implicit val tpeDispatcher = system.dispatchers.lookup("tracked-tpe") + refreshDispatcherInstruments(tpeDispatcher) collectDispatcherMetrics(tpeDispatcher) Await.result({ @@ -156,14 +158,10 @@ class DispatcherMetricsSpec extends TestKitBase with WordSpecLike with Matchers } - val collectionContext = new CollectionContext { - val buffer: LongBuffer = LongBuffer.allocate(10000) - } - def actorRecorderName(ref: ActorRef): String = ref.path.elements.mkString("/") def findDispatcherRecorder(dispatcher: MessageDispatcher): Option[EntityRecorder] = - Kamon(Metrics)(system).find(dispatcher.id, "akka-dispatcher") + Kamon.metrics.find(dispatcher.id, "akka-dispatcher") def collectDispatcherMetrics(dispatcher: MessageDispatcher): EntitySnapshot = findDispatcherRecorder(dispatcher).map(_.collect(collectionContext)).get diff --git a/kamon-akka/src/test/scala/kamon/metric/RouterMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala index 5f6bbb4f..ec55648b 100644 --- a/kamon-akka/src/test/scala/kamon/metric/RouterMetricsSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/RouterMetricsSpec.scala @@ -13,40 +13,41 @@ * ========================================================================================= */ -package kamon.metric +package kamon.akka import java.nio.LongBuffer import akka.actor._ import akka.routing._ -import akka.testkit.{ ImplicitSender, TestKitBase, TestProbe } +import akka.testkit.TestProbe import com.typesafe.config.ConfigFactory import kamon.Kamon -import kamon.akka.RouterMetrics -import kamon.metric.RouterMetricsTestActor._ +import kamon.akka.RouterMetricsTestActor._ +import kamon.metric.EntitySnapshot import kamon.metric.instrument.CollectionContext -import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } +import kamon.testkit.BaseKamonSpec import scala.concurrent.duration._ -class RouterMetricsSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender with BeforeAndAfterAll { - implicit lazy val system: ActorSystem = ActorSystem("router-metrics-spec", ConfigFactory.parseString( - """ - |kamon.metric { - | tick-interval = 1 hour - | default-collection-context-buffer-size = 10 - | - | filters = { - | akka-router { - | includes = [ "user/tracked-*", "user/measuring-*", "user/stop-*" ] - | excludes = [ "user/tracked-explicitly-excluded-*"] - | } - | } - |} - | - |akka.loglevel = OFF - | - """.stripMargin)) +class RouterMetricsSpec extends BaseKamonSpec("router-metrics-spec") { + override lazy val config = + ConfigFactory.parseString( + """ + |kamon.metric { + | tick-interval = 1 hour + | default-collection-context-buffer-size = 10 + | + | filters = { + | akka-router { + | includes = [ "user/tracked-*", "user/measuring-*", "user/stop-*" ] + | excludes = [ "user/tracked-explicitly-excluded-*"] + | } + | } + |} + | + |akka.loglevel = OFF + | + """.stripMargin) "the Kamon router metrics" should { "respect the configured include and exclude filters" in new RouterMetricsFixtures { @@ -204,7 +205,7 @@ class RouterMetricsSpec extends TestKitBase with WordSpecLike with Matchers with } def routerMetricsRecorderOf(routerName: String): Option[RouterMetrics] = - Kamon(Metrics)(system).register(RouterMetrics, routerName).map(_.recorder) + Kamon.metrics.register(RouterMetrics, routerName).map(_.recorder) def collectMetricsOf(routerName: String): Option[EntitySnapshot] = { Thread.sleep(5) // Just in case the test advances a bit faster than the actor being tested. diff --git a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala index 0d63a19e..44b90642 100644 --- a/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/instrumentation/AskPatternInstrumentationSpec.scala @@ -114,7 +114,7 @@ class AskPatternInstrumentationSpec extends BaseKamonSpec("ask-pattern-tracing-s } def setAskPatternTimeoutWarningMode(mode: String): Unit = { - val target = Kamon(Akka)(system) + val target = Kamon(Akka) val field = target.getClass.getDeclaredField("askPatternTimeoutWarning") field.setAccessible(true) field.set(target, mode) |