diff options
author | Joao Azevedo <joao.c.azevedo@gmail.com> | 2016-01-20 11:52:15 +0000 |
---|---|---|
committer | Joao Azevedo <joao.c.azevedo@gmail.com> | 2016-01-20 11:52:15 +0000 |
commit | 0e847fc55ad846e55ec8e5e80755df2aa7c95caf (patch) | |
tree | 5b6b9ce4fbb550f3c35e5e52e6a325418d75796e /kamon-system-metrics/src/main/scala | |
parent | 29ff81e41ffb31c10a1c73b54c64cabe45284349 (diff) | |
download | Kamon-0e847fc55ad846e55ec8e5e80755df2aa7c95caf.tar.gz Kamon-0e847fc55ad846e55ec8e5e80755df2aa7c95caf.tar.bz2 Kamon-0e847fc55ad846e55ec8e5e80755df2aa7c95caf.zip |
= system-metrics: apply metric filters
Diffstat (limited to 'kamon-system-metrics/src/main/scala')
3 files changed, 15 insertions, 8 deletions
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 2e9ea954..5258a81e 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 @@ -45,9 +45,11 @@ object GarbageCollectionMetrics { name.replaceAll("""[^\w]""", "-").toLowerCase def register(metricsExtension: MetricsModule): Unit = { - ManagementFactory.getGarbageCollectorMXBeans.asScala.filter(_.isValid) map { gc ⇒ + ManagementFactory.getGarbageCollectorMXBeans.asScala.filter(_.isValid) foreach { gc ⇒ val gcName = sanitizeCollectorName(gc.getName) - Kamon.metrics.entity(EntityRecorderFactory("system-metric", new GarbageCollectionMetrics(gc, _)), s"$gcName-garbage-collector") + val metricName = s"$gcName-garbage-collector" + if (metricsExtension.shouldTrack(metricName, "system-metric")) + Kamon.metrics.entity(EntityRecorderFactory("system-metric", new GarbageCollectionMetrics(gc, _)), metricName) } } } 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 2a86c13c..b5421375 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 @@ -20,8 +20,10 @@ import kamon.metric.instrument.InstrumentFactory import kamon.metric.{ MetricsModule, EntityRecorderFactory, EntityRecorder } abstract class JmxSystemMetricRecorderCompanion(metricName: String) { - def register(metricsExtension: MetricsModule): EntityRecorder = - metricsExtension.entity(EntityRecorderFactory("system-metric", apply(_)), metricName) + def register(metricsExtension: MetricsModule): Unit = { + if (metricsExtension.shouldTrack(metricName, "system-metric")) + 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 c0da6dc1..585352e4 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 @@ -38,7 +38,7 @@ class SigarMetricsUpdater(refreshInterval: FiniteDuration) extends Actor { MemoryMetrics.register(sigar, metricsExtension, logger), NetworkMetrics.register(sigar, metricsExtension, logger), ProcessCpuMetrics.register(sigar, metricsExtension, logger), - ULimitMetrics.register(sigar, metricsExtension, logger)) + ULimitMetrics.register(sigar, metricsExtension, logger)).flatten val refreshSchedule = context.system.scheduler.schedule(refreshInterval, refreshInterval, self, UpdateSigarMetrics)(context.dispatcher) @@ -83,8 +83,11 @@ object SigarSafeRunner { } abstract class SigarMetricRecorderCompanion(metricName: String) { - def register(sigar: Sigar, metricsExtension: MetricsModule, logger: LoggingAdapter = NoLogging): SigarMetric = - metricsExtension.entity(EntityRecorderFactory("system-metric", apply(sigar, _)), metricName) + def register(sigar: Sigar, metricsExtension: MetricsModule, logger: LoggingAdapter = NoLogging): Option[SigarMetric] = + if (metricsExtension.shouldTrack(metricName, "system-metric")) + Some(metricsExtension.entity(EntityRecorderFactory("system-metric", apply(sigar, _)), metricName)) + else + None def apply(sigar: Sigar, instrumentFactory: InstrumentFactory, logger: LoggingAdapter = NoLogging): SigarMetric } |