diff options
author | Boris Giftge <bgiftge@kixeye.com> | 2014-10-22 18:19:15 -0700 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-23 18:53:21 +0200 |
commit | 349b628dc483c7ec6ba4c166e25a5965c0e7d81c (patch) | |
tree | 47ae95aa8b08ad50344d8dbb1ad65ab8a0e1bf31 /kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala | |
parent | 509988c356965e3c4b40bcd4036b7dc573796e1f (diff) | |
download | Kamon-349b628dc483c7ec6ba4c166e25a5965c0e7d81c.tar.gz Kamon-349b628dc483c7ec6ba4c166e25a5965c0e7d81c.tar.bz2 Kamon-349b628dc483c7ec6ba4c166e25a5965c0e7d81c.zip |
= core,system.metrics: fixed serialization errors when using akka.actor.serialize-messages = on
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala')
-rw-r--r-- | kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala | 34 |
1 files changed, 19 insertions, 15 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 c51b458c..ac033fe2 100644 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala @@ -58,26 +58,30 @@ object HeapMetrics extends MetricGroupCategory { Committed -> committed) } - val Factory = new MetricGroupFactory { - import kamon.system.SystemMetricsExtension._ + val Factory = HeapMetricGroupFactory +} - val memory = ManagementFactory.getMemoryMXBean - def heap = memory.getHeapMemoryUsage +case object HeapMetricGroupFactory extends MetricGroupFactory { - type GroupRecorder = HeapMetricRecorder + import HeapMetrics._ + import kamon.system.SystemMetricsExtension._ - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.jvm.heap") + def heap = ManagementFactory.getMemoryMXBean.getHeapMemoryUsage - val usedHeapConfig = settings.getConfig("used") - val maxHeapConfig = settings.getConfig("max") - val committedHeapConfig = settings.getConfig("committed") + type GroupRecorder = HeapMetricRecorder - new HeapMetricRecorder( - 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))) - } + def create(config: Config, system: ActorSystem): GroupRecorder = { + val settings = config.getConfig("precision.jvm.heap") + + val usedHeapConfig = settings.getConfig("used") + val maxHeapConfig = settings.getConfig("max") + val committedHeapConfig = settings.getConfig("committed") + + new HeapMetricRecorder( + 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))) } + } |