本文整理汇总了Scala中kamon.metric.Entity类的典型用法代码示例。如果您正苦于以下问题:Scala Entity类的具体用法?Scala Entity怎么用?Scala Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: CellInfo
//设置package包名称以及导入依赖的类
package akka.kamon.instrumentation
import akka.actor.{ Cell, ActorRef, ActorSystem }
import akka.routing.{ NoRouter, RoutedActorRef, RoutedActorCell }
import kamon.Kamon
import kamon.akka.{ ActorMetrics, ActorGroupConfig, RouterMetrics }
import kamon.metric.Entity
case class CellInfo(entity: Entity, isRouter: Boolean, isRoutee: Boolean,
isTracked: Boolean, trackingGroups: List[String], actorCellCreation: 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, actorCellCreation: Boolean): CellInfo = {
import kamon.metric.Entity
def hasRouterProps(cell: Cell): Boolean = cell.props.deploy.routerConfig != NoRouter
val pathString = ref.path.elements.mkString("/")
val isRootSupervisor = pathString.length == 0 || pathString == "user" || pathString == "system"
val isRouter = hasRouterProps(cell)
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)
val trackingGroups = if(isRootSupervisor) List() else ActorGroupConfig.actorShouldBeTrackedUnderGroups(name)
CellInfo(entity, isRouter, isRoutee, isTracked, trackingGroups, actorCellCreation)
}
}