diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2016-03-15 23:31:11 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2016-03-15 23:31:11 +0100 |
commit | 60880bb1b6ec15f40ecacf5ab46c849a86ce4b60 (patch) | |
tree | 0fe880c75b891b99f3503d876b3f7e98de11a67b /kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala | |
parent | cf45b7bcac148945ff209fd7abefc761d916be9a (diff) | |
parent | 9e52aad6b02da72ca28d52d0c94e2e8784e7aa65 (diff) | |
download | Kamon-60880bb1b6ec15f40ecacf5ab46c849a86ce4b60.tar.gz Kamon-60880bb1b6ec15f40ecacf5ab46c849a86ce4b60.tar.bz2 Kamon-60880bb1b6ec15f40ecacf5ab46c849a86ce4b60.zip |
Merge branch 'issue#271/fix-balancing-pool-metrics'
Diffstat (limited to 'kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala')
-rw-r--r-- | kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala new file mode 100644 index 00000000..e144e605 --- /dev/null +++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/CellInfo.scala @@ -0,0 +1,31 @@ +package akka.kamon.instrumentation + +import akka.actor.{ Cell, ActorRef, ActorSystem } +import akka.routing.{ RoutedActorRef, RoutedActorCell } +import kamon.Kamon +import kamon.akka.{ ActorMetrics, RouterMetrics } +import kamon.metric.Entity + +case class CellInfo(entity: Entity, isRouter: Boolean, isRoutee: Boolean, isTracked: Boolean) + +object CellInfo { + + def cellName(system: ActorSystem, ref: ActorRef): String = + system.name + "/" + ref.path.elements.mkString("/") + + def cellInfoFor(cell: Cell, system: ActorSystem, ref: ActorRef, parent: ActorRef): CellInfo = { + import kamon.metric.Entity + + val pathString = ref.path.elements.mkString("/") + val isRootSupervisor = pathString.length == 0 || pathString == "user" || pathString == "system" + val isRouter = cell.isInstanceOf[RoutedActorCell] + val isRoutee = parent.isInstanceOf[RoutedActorRef] + + val name = if (isRoutee) cellName(system, parent) else cellName(system, ref) + val category = if (isRouter || isRoutee) RouterMetrics.category else ActorMetrics.category + val entity = Entity(name, category) + val isTracked = !isRootSupervisor && Kamon.metrics.shouldTrack(entity) + + CellInfo(entity, isRouter, isRoutee, isTracked) + } +}
\ No newline at end of file |