diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-03-13 16:53:28 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-03-13 16:53:28 +0100 |
commit | 3b6977edda25b98914a567f690bce9aecbb60d64 (patch) | |
tree | c38589f5b34b028734401cb7bee361e7401095e3 /kamon-akka/src | |
parent | 0bb77ab8d744f57d70db846d3746c5e5878e56ee (diff) | |
download | Kamon-3b6977edda25b98914a567f690bce9aecbb60d64.tar.gz Kamon-3b6977edda25b98914a567f690bce9aecbb60d64.tar.bz2 Kamon-3b6977edda25b98914a567f690bce9aecbb60d64.zip |
! akka: avoid catching the root supervisors with the metrics instrumentation, fixes #157.
Diffstat (limited to 'kamon-akka/src')
3 files changed, 11 insertions, 5 deletions
diff --git a/kamon-akka/src/main/resources/reference.conf b/kamon-akka/src/main/resources/reference.conf index 47ce073b..c1e59e63 100644 --- a/kamon-akka/src/main/resources/reference.conf +++ b/kamon-akka/src/main/resources/reference.conf @@ -17,7 +17,7 @@ kamon { metric.filters { akka-actor { includes = [] - excludes = [ "", "*/user", "*/system**", "*/user/IO-**" ] + excludes = [ "*/system/**", "*/user/IO-**" ] } akka-router { diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala index 39bdcfe0..deb43499 100644 --- a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala +++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala @@ -34,16 +34,18 @@ class ActorCellInstrumentation { @After("actorCellCreation(cell, system, ref, props, dispatcher, parent)") def afterCreation(cell: ActorCell, system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): Unit = { - val actorEntity = Entity(system.name + "/" + ref.path.elements.mkString("/"), ActorMetrics.category) + def isRootSupervisor(path: String): Boolean = path.length == 0 || path == "user" || path == "system" - if (Kamon.metrics.shouldTrack(actorEntity)) { + val pathString = ref.path.elements.mkString("/") + val actorEntity = Entity(system.name + "/" + pathString, ActorMetrics.category) + + if (!isRootSupervisor(pathString) && Kamon.metrics.shouldTrack(actorEntity)) { val actorMetricsRecorder = Kamon.metrics.entity(ActorMetrics, actorEntity) val cellMetrics = cell.asInstanceOf[ActorCellMetrics] cellMetrics.entity = actorEntity cellMetrics.recorder = Some(actorMetricsRecorder) } - } @Pointcut("execution(* akka.actor.ActorCell.invoke(*)) && this(cell) && args(envelope)") diff --git a/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala index cef0071b..4647abc0 100644 --- a/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala +++ b/kamon-akka/src/test/scala/kamon/akka/ActorMetricsSpec.scala @@ -38,7 +38,7 @@ class ActorMetricsSpec extends BaseKamonSpec("actor-metrics-spec") { | | filters { | akka-actor { - | includes = [ "*/user/tracked-*", "*/user/measuring-*", "*/user/clean-after-collect", "*/user/stop" ] + | includes = [ "*/user/tracked-*", "*/user/measuring-*", "*/user/clean-after-collect", "*/user/stop", "*/" ] | excludes = [ "*/user/tracked-explicitly-excluded", "*/user/non-tracked-actor" ] | } | } @@ -64,6 +64,10 @@ class ActorMetricsSpec extends BaseKamonSpec("actor-metrics-spec") { actorMetricsRecorderOf(trackedButExplicitlyExcluded) shouldBe empty } + "not pick up the root supervisor" in { + Kamon.metrics.find("actor-metrics-spec/", ActorMetrics.category) shouldBe empty + } + "reset all recording instruments after taking a snapshot" in new ActorMetricsFixtures { val trackedActor = createTestActor("clean-after-collect") |