diff options
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon')
3 files changed, 7 insertions, 5 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala index c098d1e5..a45896ac 100644 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala @@ -17,10 +17,9 @@ package kamon.metrics import akka.actor.ActorSystem import com.typesafe.config.Config -import kamon.metric.instrument.{ Gauge, Histogram } import kamon.metric._ +import kamon.metric.instrument.{Gauge, Histogram} import kamon.system.SigarExtensionProvider -import org.hyperic.sigar.SigarProxy case class CPUMetrics(name: String) extends MetricGroupIdentity { val category = CPUMetrics @@ -61,6 +60,7 @@ object CPUMetrics extends MetricGroupCategory { } val Factory = new MetricGroupFactory with SigarExtensionProvider { + def cpu = sigar.getCpu type GroupRecorder = CPUMetricRecorder 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 e46fca24..a46d8e1f 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetrics.scala @@ -62,3 +62,4 @@ object SystemMetricsExtension { trait SigarExtensionProvider { lazy val sigar = SigarLoader.sigarProxy } + diff --git a/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala b/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala index 6af0a6d2..f1072f56 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/native/SigarLoader.scala @@ -21,7 +21,8 @@ import java.util import java.util.logging.Logger import java.util.{ ArrayList, List } -import org.hyperic.sigar.{ SigarProxy, SigarProxyCache } +import kamon.system.SynchronizedSigar +import org.hyperic.sigar.SigarProxy import scala.annotation.tailrec import scala.collection.JavaConversions._ @@ -37,7 +38,7 @@ object SigarLoader { private val log = Logger.getLogger("SigarLoader") - def sigarProxy = init(new File(System.getProperty(TmpDir))) + lazy val sigarProxy = init(new File(System.getProperty(TmpDir))) private[native] def init(baseTmp: File): SigarProxy = { val tmpDir = createTmpDir(baseTmp) @@ -46,7 +47,7 @@ object SigarLoader { attachToLibraryPath(tmpDir) try { - val sigar = SigarProxyCache.newInstance() + val sigar = new SynchronizedSigar() sigar.getPid sigar } catch { |