diff options
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/system')
4 files changed, 10 insertions, 17 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/system/custom/ContextSwitchesMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/system/custom/ContextSwitchesMetrics.scala index 384c89f1..5090f3dd 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/custom/ContextSwitchesMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/custom/ContextSwitchesMetrics.scala @@ -88,12 +88,10 @@ class ContextSwitchesMetrics(pid: Long, log: LoggingAdapter, instrumentFactory: object ContextSwitchesMetrics { def register(system: ActorSystem, refreshInterval: FiniteDuration): ContextSwitchesMetrics = { - val metricsExtension = Kamon.metrics val log = Logging(system, "ContextSwitchesMetrics") val pid = (new Sigar).getPid - val instrumentFactory = metricsExtension.instrumentFactory("system-metric") - metricsExtension.register(Entity("context-switches", "system-metric"), new ContextSwitchesMetrics(pid, log, instrumentFactory)).recorder + Kamon.metrics.entity(EntityRecorderFactory("system-metric", new ContextSwitchesMetrics(pid, log, _)), "context-switches") } } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/jmx/GarbageCollectionMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/system/jmx/GarbageCollectionMetrics.scala index 59d4050c..7a5770d8 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/jmx/GarbageCollectionMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/jmx/GarbageCollectionMetrics.scala @@ -18,7 +18,8 @@ package kamon.system.jmx import java.lang.management.{ GarbageCollectorMXBean, ManagementFactory } -import kamon.metric.{ Entity, Metrics, GenericEntityRecorder } +import kamon.Kamon +import kamon.metric.{ EntityRecorderFactory, Entity, Metrics, GenericEntityRecorder } import kamon.metric.instrument.{ DifferentialValueCollector, Time, InstrumentFactory } import scala.collection.JavaConverters._ @@ -44,11 +45,9 @@ object GarbageCollectionMetrics { name.replaceAll("""[^\w]""", "-").toLowerCase def register(metricsExtension: Metrics): Unit = { - - val instrumentFactory = metricsExtension.instrumentFactory("system-metric") ManagementFactory.getGarbageCollectorMXBeans.asScala.filter(_.isValid) map { gc ⇒ val gcName = sanitizeCollectorName(gc.getName) - metricsExtension.register(Entity(s"$gcName-garbage-collector", "system-metric"), new GarbageCollectionMetrics(gc, instrumentFactory)) + Kamon.metrics.entity(EntityRecorderFactory("system-metric", new GarbageCollectionMetrics(gc, _)), s"$gcName-garbage-collector") } } } diff --git a/kamon-system-metrics/src/main/scala/kamon/system/jmx/JmxSystemMetricRecorderCompanion.scala b/kamon-system-metrics/src/main/scala/kamon/system/jmx/JmxSystemMetricRecorderCompanion.scala index 8837aec0..15bd399e 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/jmx/JmxSystemMetricRecorderCompanion.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/jmx/JmxSystemMetricRecorderCompanion.scala @@ -17,13 +17,11 @@ package kamon.system.jmx import kamon.metric.instrument.InstrumentFactory -import kamon.metric.{ Entity, EntityRecorder, Metrics } +import kamon.metric.{ EntityRecorderFactory, EntityRecorder, Metrics } abstract class JmxSystemMetricRecorderCompanion(metricName: String) { - def register(metricsExtension: Metrics): EntityRecorder = { - val instrumentFactory = metricsExtension.instrumentFactory("system-metric") - metricsExtension.register(Entity(metricName, "system-metric"), apply(instrumentFactory)).recorder - } + def register(metricsExtension: Metrics): EntityRecorder = + metricsExtension.entity(EntityRecorderFactory("system-metric", apply(_)), metricName) def apply(instrumentFactory: InstrumentFactory): EntityRecorder }
\ No newline at end of file diff --git a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarMetricsUpdater.scala b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarMetricsUpdater.scala index 68b133b0..a1bd3e01 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarMetricsUpdater.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/sigar/SigarMetricsUpdater.scala @@ -19,7 +19,7 @@ package kamon.system.sigar import akka.actor.{ Props, Actor } import kamon.Kamon import kamon.metric.instrument.InstrumentFactory -import kamon.metric.{ Entity, EntityRecorder, Metrics } +import kamon.metric.{ EntityRecorderFactory, Entity, EntityRecorder, Metrics } import kamon.system.sigar.SigarMetricsUpdater.UpdateSigarMetrics import org.hyperic.sigar.Sigar @@ -65,10 +65,8 @@ trait SigarMetric extends EntityRecorder { } abstract class SigarMetricRecorderCompanion(metricName: String) { - def register(sigar: Sigar, metricsExtension: Metrics): SigarMetric = { - val instrumentFactory = metricsExtension.instrumentFactory("system-metric") - metricsExtension.register(Entity(metricName, "system-metric"), apply(sigar, instrumentFactory)).recorder - } + def register(sigar: Sigar, metricsExtension: Metrics): SigarMetric = + metricsExtension.entity(EntityRecorderFactory("system-metric", apply(sigar, _)), metricName) def apply(sigar: Sigar, instrumentFactory: InstrumentFactory): SigarMetric } |