diff options
author | Diego <diegolparra@gmail.com> | 2014-08-16 23:13:56 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-08-16 23:13:56 -0300 |
commit | 92a258f5f5e54cde7c7c85bfd76a2f9d7c532551 (patch) | |
tree | 644f83355041021b3ed7a1e342bf50a740880ad5 /kamon-log-reporter/src/main/scala | |
parent | 9fe3750f7cf8b3a85f7db8ebd1cc8daff097935e (diff) | |
download | Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.tar.gz Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.tar.bz2 Kamon-92a258f5f5e54cde7c7c85bfd76a2f9d7c532551.zip |
+ log-reporter: include Process Cpu metrics and closes #72
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 d58c6330..307343de 100644 --- a/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala +++ b/kamon-log-reporter/src/main/scala/kamon/logreporter/LogReporter.scala @@ -25,9 +25,11 @@ import kamon.metric.TraceMetrics.TraceMetricsSnapshot import kamon.metric.UserMetrics._ import kamon.metric._ import kamon.metric.instrument.{ Counter, Histogram } +import kamon.metrics.GCMetrics.GCMetricSnapshot import kamon.metrics.MemoryMetrics.MemoryMetricSnapshot import kamon.metrics.NetworkMetrics.NetworkMetricSnapshot -import kamon.metrics.{ NetworkMetrics, MemoryMetrics, CPUMetrics } +import kamon.metrics.ProcessCPUMetrics.ProcessCPUMetricsSnapshot +import kamon.metrics._ import kamon.metrics.CPUMetrics.CPUMetricSnapshot object LogReporter extends ExtensionId[LogReporterExtension] with ExtensionIdProvider { @@ -57,11 +59,12 @@ class LogReporterExtension(system: ExtendedActorSystem) extends Kamon.Extension Kamon(Metrics)(system).subscribe(UserMinMaxCounters, "*", subscriber, permanently = true) Kamon(Metrics)(system).subscribe(UserGauges, "*", subscriber, permanently = true) - // Subscribe to SystemMetrics val includeSystemMetrics = logReporterConfig.getBoolean("report-system-metrics") if (includeSystemMetrics) { + // Subscribe to SystemMetrics Kamon(Metrics)(system).subscribe(CPUMetrics, "*", subscriber, permanently = true) + Kamon(Metrics)(system).subscribe(ProcessCPUMetrics, "*", subscriber, permanently = true) Kamon(Metrics)(system).subscribe(NetworkMetrics, "*", subscriber, permanently = true) } @@ -89,6 +92,7 @@ class LogReporterSubscriber extends Actor with ActorLogging { case (m: UserMinMaxCounter, s: UserMinMaxCounterSnapshot) ⇒ minMaxCounters += (m -> s.minMaxCounterSnapshot) case (g: UserGauge, s: UserGaugeSnapshot) ⇒ gauges += (g -> s.gaugeSnapshot) case (_, cms: CPUMetricSnapshot) ⇒ logCpuMetrics(cms) + case (_, pcms: ProcessCPUMetricsSnapshot) ⇒ logProcessCpuMetrics(pcms) case (_, nms: NetworkMetricSnapshot) ⇒ logNetworkMetrics(nms) case ignoreEverythingElse ⇒ } @@ -137,7 +141,7 @@ class LogReporterSubscriber extends Actor with ActorLogging { || | || User (percentage) System (percentage) Wait (percentage) Idle (percentage) | || Min: %-3s Min: %-3s Min: %-3s Min: %-3s | - || Avg: %-3s Avg: %-3s Avg: %-3s Avg: %-3s | + || Avg: %-3s Avg: %-3s Avg: %-3s Avg: %-3s | || Max: %-3s Max: %-3s Max: %-3s Max: %-3s | || | || | @@ -170,6 +174,27 @@ class LogReporterSubscriber extends Actor with ActorLogging { rxBytes.max, txBytes.max)) } + def logProcessCpuMetrics(pcms: ProcessCPUMetricsSnapshot): Unit = { + import pcms._ + + log.info( + """ + |+--------------------------------------------------------------------------------------------------+ + || | + || Process-CPU | + || | + || Cpu-Percentage Total-Process-Time | + || Min: %-12s Min: %-12s | + || Avg: %-12s Avg: %-12s | + || Max: %-12s Max: %-12s | + || | + |+--------------------------------------------------------------------------------------------------+""" + .stripMargin.format( + (cpuPercent.min / 100), totalProcessTime.min, + (cpuPercent.average / 100), totalProcessTime.average, + (cpuPercent.max / 100), totalProcessTime.max)) + } + def logTraceMetrics(name: String, tms: TraceMetricsSnapshot): Unit = { val traceMetricsData = StringBuilder.newBuilder |