diff options
author | Diego <diegolparra@gmail.com> | 2014-10-20 23:19:32 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-10-20 23:19:32 -0300 |
commit | 6fa0ae383c409cb8f70f57300d9ac993af5a3481 (patch) | |
tree | 52cfe6a3d39c81d4f8e1604b0b91bd631837743b /kamon-log-reporter/src/main/scala | |
parent | 40c6f3e80b6920954003edeb29d985ad96553e21 (diff) | |
download | Kamon-6fa0ae383c409cb8f70f57300d9ac993af5a3481.tar.gz Kamon-6fa0ae383c409cb8f70f57300d9ac993af5a3481.tar.bz2 Kamon-6fa0ae383c409cb8f70f57300d9ac993af5a3481.zip |
+ log-reporter: introduce ContextSwitches metrics
Diffstat (limited to 'kamon-log-reporter/src/main/scala')
-rw-r--r-- | kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala | 31 |
1 files changed, 28 insertions, 3 deletions
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 41ecb757..560fe5ae 100644 --- a/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala +++ b/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala @@ -25,6 +25,7 @@ import kamon.metric.TraceMetrics.TraceMetricsSnapshot import kamon.metric.UserMetrics._ import kamon.metric._ import kamon.metric.instrument.{ Counter, Histogram } +import kamon.metrics.ContextSwitchesMetrics.ContextSwitchesMetricsSnapshot import kamon.metrics.GCMetrics.GCMetricSnapshot import kamon.metrics.MemoryMetrics.MemoryMetricSnapshot import kamon.metrics.NetworkMetrics.NetworkMetricSnapshot @@ -66,6 +67,7 @@ class LogReporterExtension(system: ExtendedActorSystem) extends Kamon.Extension Kamon(Metrics)(system).subscribe(CPUMetrics, "*", subscriber, permanently = true) Kamon(Metrics)(system).subscribe(ProcessCPUMetrics, "*", subscriber, permanently = true) Kamon(Metrics)(system).subscribe(NetworkMetrics, "*", subscriber, permanently = true) + Kamon(Metrics)(system).subscribe(ContextSwitchesMetrics, "*", subscriber, permanently = true) } } @@ -94,6 +96,7 @@ class LogReporterSubscriber extends Actor with ActorLogging { case (_, cms: CPUMetricSnapshot) ⇒ logCpuMetrics(cms) case (_, pcms: ProcessCPUMetricsSnapshot) ⇒ logProcessCpuMetrics(pcms) case (_, nms: NetworkMetricSnapshot) ⇒ logNetworkMetrics(nms) + case (_, csms: ContextSwitchesMetricsSnapshot) ⇒ logContextSwitchesMetrics(csms) case ignoreEverythingElse ⇒ } @@ -163,9 +166,9 @@ class LogReporterSubscriber extends Actor with ActorLogging { || Network (ALL) | || | || Rx-Bytes (KB) Tx-Bytes (KB) Rx-Errors Tx-Errors | - || Min: %-4s Min: %-4s Total: %-8s Total: %-8s| - || Avg: %-4s Avg: %-4s | - || Max: %-4s Max: %-4s | + || Min: %-4s Min: %-4s Total: %-8s Total: %-8s | + || Avg: %-4s Avg: %-4s | + || Max: %-4s Max: %-4s | || | |+--------------------------------------------------------------------------------------------------+""" .stripMargin.format( @@ -195,6 +198,28 @@ class LogReporterSubscriber extends Actor with ActorLogging { (cpuPercent.max / 100), totalProcessTime.max)) } + def logContextSwitchesMetrics(csms: ContextSwitchesMetricsSnapshot): Unit = { + import csms._ + + log.info( + """ + |+--------------------------------------------------------------------------------------------------+ + || | + || Context-Switches | + || | + || Global Per-Process-Non-Voluntary Per-Process-Voluntary | + || Min: %-12s Min: %-12s Min: %-12s | + || Avg: %-12s Avg: %-12s Avg: %-12s | + || Max: %-12s Max: %-12s Max: %-12s | + || | + |+--------------------------------------------------------------------------------------------------+""" + .stripMargin.format( + global.min, perProcessNonVoluntary.min, perProcessVoluntary.min, + global.average, perProcessNonVoluntary.average, perProcessVoluntary.average, + global.max, perProcessNonVoluntary.max,perProcessVoluntary.max)) + + } + def logTraceMetrics(name: String, tms: TraceMetricsSnapshot): Unit = { val traceMetricsData = StringBuilder.newBuilder |