diff options
author | Diego <diegolparra@gmail.com> | 2014-07-25 22:22:24 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-07-25 22:22:24 -0300 |
commit | e00ee2d4a782e348ab79de4c0f00fa8e1b2ad9d6 (patch) | |
tree | 33a18329c43896eb640fb478d2aaa5ac8508585d /kamon-system-metrics/src/main | |
parent | 007d17bb0b368dc943af2b75d77d8bc5de75b1f2 (diff) | |
download | Kamon-e00ee2d4a782e348ab79de4c0f00fa8e1b2ad9d6.tar.gz Kamon-e00ee2d4a782e348ab79de4c0f00fa8e1b2ad9d6.tar.bz2 Kamon-e00ee2d4a782e348ab79de4c0f00fa8e1b2ad9d6.zip |
= kamon-system-metrics: source format
Diffstat (limited to 'kamon-system-metrics/src/main')
4 files changed, 17 insertions, 16 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala index 96e030ae..c51b458c 100644 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala @@ -74,7 +74,7 @@ object HeapMetrics extends MetricGroupCategory { val committedHeapConfig = settings.getConfig("committed") new HeapMetricRecorder( - Gauge.fromConfig(usedHeapConfig, system,Scale.Mega)(() ⇒ toMB(heap.getUsed)), + Gauge.fromConfig(usedHeapConfig, system, Scale.Mega)(() ⇒ toMB(heap.getUsed)), Gauge.fromConfig(maxHeapConfig, system, Scale.Mega)(() ⇒ toMB(heap.getMax)), Gauge.fromConfig(committedHeapConfig, system, Scale.Mega)(() ⇒ toMB(heap.getCommitted))) } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala index 22ae504c..afd30bed 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala @@ -58,7 +58,7 @@ object SystemMetricsExtension { val garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans.asScala.filter(_.isValid) - def toKB(value:Long):Long = (value / 1024) - def toMB(value:Long):Long = (value / 1024 / 1024) - def toLong(value:Double):Long = math round (value * 100L) + def toKB(value: Long): Long = (value / 1024) + def toMB(value: Long): Long = (value / 1024 / 1024) + def toLong(value: Double): Long = math round (value * 100L) } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala index 735a3c79..fde9820a 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala @@ -15,15 +15,15 @@ */ package kamon.system -import akka.actor.{Props, Actor} +import akka.actor.{ Props, Actor } import kamon.Kamon import kamon.metric.Metrics import kamon.metrics.CPUMetrics.CPUMetricRecorder import kamon.metrics.MemoryMetrics.MemoryMetricRecorder import kamon.metrics.NetworkMetrics.NetworkMetricRecorder import kamon.metrics.ProcessCPUMetrics.ProcessCPUMetricsRecorder -import kamon.metrics.{NetworkMetrics, MemoryMetrics, ProcessCPUMetrics, CPUMetrics} -import org.hyperic.sigar.{NetInterfaceStat, SigarProxy, Mem} +import kamon.metrics.{ NetworkMetrics, MemoryMetrics, ProcessCPUMetrics, CPUMetrics } +import org.hyperic.sigar.{ NetInterfaceStat, SigarProxy, Mem } import scala.concurrent.duration.FiniteDuration @@ -61,12 +61,12 @@ class SystemMetricsCollector(collectInterval: FiniteDuration) extends Actor with cpur.idle.record(toLong(cpu.getIdle)) } - private def recordProcessCpu(pcpur:ProcessCPUMetricsRecorder) ={ + private def recordProcessCpu(pcpur: ProcessCPUMetricsRecorder) = { pcpur.user.record(procCpu.getUser) pcpur.system.record(procCpu.getSys) } - private def recordMemory(mr:MemoryMetricRecorder) = { + private def recordMemory(mr: MemoryMetricRecorder) = { mr.used.record(toMB(mem.getUsed)) mr.free.record(toMB(mem.getFree)) mr.swapUsed.record(toMB(swap.getUsed)) @@ -78,17 +78,18 @@ class SystemMetricsCollector(collectInterval: FiniteDuration) extends Actor with def collectCache(mem: Mem): Long = if (mem.getFree() != mem.getActualFree()) mem.getActualFree() else 0L } - private def recordNetwork(nr:NetworkMetricRecorder) = { + private def recordNetwork(nr: NetworkMetricRecorder) = { nr.rxBytes.record(collect(sigar, interfaces)(net ⇒ toKB(net.getRxBytes))) nr.txBytes.record(collect(sigar, interfaces)(net ⇒ toKB(net.getTxBytes))) nr.rxErrors.record(collect(sigar, interfaces)(net ⇒ net.getRxErrors)) nr.txErrors.record(collect(sigar, interfaces)(net ⇒ net.getTxErrors)) def collect(sigar: SigarProxy, interfaces: Set[String])(block: NetInterfaceStat ⇒ Long): Long = { - interfaces.foldLeft(0L) { (totalBytes, interface) ⇒ { - val net = sigar.getNetInterfaceStat(interface) - totalBytes + block(net) - } + interfaces.foldLeft(0L) { (totalBytes, interface) ⇒ + { + val net = sigar.getNetInterfaceStat(interface) + totalBytes + block(net) + } } } } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala index e78c71f4..5f858b42 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarLoader.scala @@ -19,9 +19,9 @@ package kamon.system.sigar import java.io._ import java.util import java.util.logging.Logger -import java.util.{ArrayList, List} +import java.util.{ ArrayList, List } -import org.hyperic.sigar.{Sigar, SigarProxy} +import org.hyperic.sigar.{ Sigar, SigarProxy } import scala.annotation.tailrec import scala.collection.JavaConversions._ |