diff options
author | Diego Parra <diegolparra@gmail.com> | 2016-02-02 11:27:37 -0300 |
---|---|---|
committer | Diego Parra <diegolparra@gmail.com> | 2016-02-02 11:27:37 -0300 |
commit | b23ea502a2589d569e6917b40e90b50dc2457e7a (patch) | |
tree | b5545374f051d4986a12f2eb5a345ac8cc030ec4 | |
parent | 024973f193c8575db2af68b8984a06f744a70f5e (diff) | |
parent | c1e03d38641100e683f1ad60035841b7091ca3ed (diff) | |
download | Kamon-b23ea502a2589d569e6917b40e90b50dc2457e7a.tar.gz Kamon-b23ea502a2589d569e6917b40e90b50dc2457e7a.tar.bz2 Kamon-b23ea502a2589d569e6917b40e90b50dc2457e7a.zip |
Merge pull request #310 from jtjeferreira/log-reporter-akka-router
+ log-reporter: add akka-router subscription
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala | 44 |
2 files changed, 46 insertions, 0 deletions
@@ -28,6 +28,8 @@ project/plugins/project/ .settings .classpath .cache +.cache-main +.cache-tests bin/ _site diff --git a/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala b/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala index 96995c00..c1a23f1d 100644 --- a/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala +++ b/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala @@ -36,6 +36,7 @@ class LogReporterExtension(system: ExtendedActorSystem) extends Kamon.Extension Kamon.metrics.subscribe("trace", "**", subscriber, permanently = true) Kamon.metrics.subscribe("akka-actor", "**", subscriber, permanently = true) + Kamon.metrics.subscribe("akka-router", "**", subscriber, permanently = true) Kamon.metrics.subscribe("akka-dispatcher", "**", subscriber, permanently = true) Kamon.metrics.subscribe("counter", "**", subscriber, permanently = true) Kamon.metrics.subscribe("histogram", "**", subscriber, permanently = true) @@ -61,6 +62,7 @@ class LogReporterSubscriber extends Actor with ActorLogging { tick.metrics foreach { case (entity, snapshot) if entity.category == "akka-actor" ⇒ logActorMetrics(entity.name, snapshot) + case (entity, snapshot) if entity.category == "akka-router" ⇒ logRouterMetrics(entity.name, snapshot) case (entity, snapshot) if entity.category == "akka-dispatcher" ⇒ logDispatcherMetrics(entity, snapshot) case (entity, snapshot) if entity.category == "trace" ⇒ logTraceMetrics(entity.name, snapshot) case (entity, snapshot) if entity.category == "histogram" ⇒ histograms += (entity.name -> snapshot.histogram("histogram")) @@ -113,6 +115,48 @@ class LogReporterSubscriber extends Actor with ActorLogging { } + def logRouterMetrics(name: String, actorSnapshot: EntitySnapshot): Unit = { + for { + processingTime ← actorSnapshot.histogram("processing-time") + timeInMailbox ← actorSnapshot.histogram("time-in-mailbox") + routingTime ← actorSnapshot.histogram("routing-time") + errors ← actorSnapshot.counter("errors") + } { + + log.info( + """ + |+--------------------------------------------------------------------------------------------------+ + || | + || Router: %-83s | + || | + || Processing Time (nanoseconds) Time in Mailbox (nanoseconds) Routing Time (nanoseconds) | + || Msg Count: %-12s Msg Count: %-12s Msg Count: %-12s | + || Min: %-12s Min: %-12s Min: %-12s | + || 50th Perc: %-12s 50th Perc: %-12s 50th Perc: %-12s | + || 90th Perc: %-12s 90th Perc: %-12s 90th Perc: %-12s | + || 95th Perc: %-12s 95th Perc: %-12s 95th Perc: %-12s | + || 99th Perc: %-12s 99th Perc: %-12s 99th Perc: %-12s | + || 99.9th Perc: %-12s 99.9th Perc: %-12s 99.9th Perc: %-12s | + || Max: %-12s Max: %-12s Max: %-12s | + || | + || Error Count: %-6s | + || | + |+--------------------------------------------------------------------------------------------------+""" + .stripMargin.format( + name, + processingTime.numberOfMeasurements, timeInMailbox.numberOfMeasurements, routingTime.numberOfMeasurements, + processingTime.min, timeInMailbox.min, routingTime.min, + processingTime.percentile(50.0D), timeInMailbox.percentile(50.0D), routingTime.percentile(50.0D), + processingTime.percentile(90.0D), timeInMailbox.percentile(90.0D), routingTime.percentile(90.0D), + processingTime.percentile(95.0D), timeInMailbox.percentile(95.0D), routingTime.percentile(95.0D), + processingTime.percentile(99.0D), timeInMailbox.percentile(99.0D), routingTime.percentile(99.0D), + processingTime.percentile(99.9D), timeInMailbox.percentile(99.9D), routingTime.percentile(99.9D), + processingTime.max, timeInMailbox.max, routingTime.max, + errors.count)) + } + + } + def logDispatcherMetrics(entity: Entity, snapshot: EntitySnapshot): Unit = entity.tags.get("dispatcher-type") match { case Some("fork-join-pool") ⇒ logForkJoinPool(entity.name, snapshot) case Some("thread-pool-executor") ⇒ logThreadPoolExecutor(entity.name, snapshot) |