aboutsummaryrefslogtreecommitdiff
path: root/kamon-system-metrics/src/main/scala/kamon/metrics
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/metrics')
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala85
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala85
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala11
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala6
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala80
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala86
-rw-r--r--kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala85
7 files changed, 429 insertions, 9 deletions
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala
new file mode 100644
index 00000000..1e3bee27
--- /dev/null
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala
@@ -0,0 +1,85 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2014 the kamon project <http://kamon.io/>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ * =========================================================================================
+ */
+package kamon.metrics
+
+import java.lang.management.ManagementFactory
+
+import akka.actor.ActorSystem
+import com.typesafe.config.Config
+import kamon.metric._
+import kamon.metric.instrument.{ Gauge, Histogram }
+
+case class ClassLoadingMetrics(name: String) extends MetricGroupIdentity {
+ val category = ClassLoadingMetrics
+}
+
+object ClassLoadingMetrics extends MetricGroupCategory {
+ val name = "classes"
+
+ case object Loaded extends MetricIdentity { val name = "total-loaded" }
+ case object Unloaded extends MetricIdentity { val name = "total-unloaded" }
+ case object Current extends MetricIdentity { val name = "current-loaded" }
+
+ case class ClassLoadingMetricRecorder(loaded: Gauge, unloaded: Gauge, current: Gauge)
+ extends MetricGroupRecorder {
+
+ def collect(context: CollectionContext): MetricGroupSnapshot = {
+ ClassLoadingMetricSnapshot(loaded.collect(context), unloaded.collect(context), current.collect(context))
+ }
+
+ def cleanup: Unit = {}
+ }
+
+ case class ClassLoadingMetricSnapshot(loaded: Histogram.Snapshot, unloaded: Histogram.Snapshot, current: Histogram.Snapshot)
+ extends MetricGroupSnapshot {
+
+ type GroupSnapshotType = ClassLoadingMetricSnapshot
+
+ def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = {
+ ClassLoadingMetricSnapshot(loaded.merge(that.loaded, context), unloaded.merge(that.unloaded, context), current.merge(that.current, context))
+ }
+
+ lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map(
+ Loaded -> loaded,
+ Unloaded -> unloaded,
+ Current -> current)
+ }
+
+ val Factory = ClassLoadingMetricGroupFactory
+}
+
+case object ClassLoadingMetricGroupFactory extends MetricGroupFactory {
+
+ import ClassLoadingMetrics._
+
+ val classes = ManagementFactory.getClassLoadingMXBean
+
+ type GroupRecorder = ClassLoadingMetricRecorder
+
+ def create(config: Config, system: ActorSystem): GroupRecorder = {
+ val settings = config.getConfig("precision.jvm.classes")
+
+ val totalLoadedConfig = settings.getConfig("total-loaded")
+ val totalUnloadedConfig = settings.getConfig("total-unloaded")
+ val currentLoadedConfig = settings.getConfig("current-loaded")
+
+ new ClassLoadingMetricRecorder(
+ Gauge.fromConfig(totalLoadedConfig, system)(() ⇒ classes.getTotalLoadedClassCount),
+ Gauge.fromConfig(totalUnloadedConfig, system)(() ⇒ classes.getUnloadedClassCount),
+ Gauge.fromConfig(currentLoadedConfig, system)(() ⇒ classes.getLoadedClassCount.toLong))
+ }
+}
+
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala
new file mode 100644
index 00000000..eeb6002b
--- /dev/null
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala
@@ -0,0 +1,85 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2014 the kamon project <http://kamon.io/>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ * =========================================================================================
+ */
+package kamon.metrics
+
+import akka.actor.ActorSystem
+import com.typesafe.config.Config
+import kamon.metric._
+import kamon.metric.instrument.Histogram
+
+case class DiskMetrics(name: String) extends MetricGroupIdentity {
+ val category = DiskMetrics
+}
+
+object DiskMetrics extends MetricGroupCategory {
+ val name = "disk"
+
+ case object Reads extends MetricIdentity { val name = "reads" }
+ case object Writes extends MetricIdentity { val name = "writes" }
+ case object Queue extends MetricIdentity { val name = "queue" }
+ case object ServiceTime extends MetricIdentity { val name = "service-time" }
+
+ case class DiskMetricsRecorder(reads: Histogram, writes: Histogram, queue: Histogram, serviceTime: Histogram)
+ extends MetricGroupRecorder {
+
+ def collect(context: CollectionContext): MetricGroupSnapshot = {
+ DiskMetricsSnapshot(reads.collect(context), writes.collect(context), queue.collect(context), serviceTime.collect(context))
+ }
+
+ def cleanup: Unit = {}
+ }
+
+ case class DiskMetricsSnapshot(reads: Histogram.Snapshot, writes: Histogram.Snapshot, queue: Histogram.Snapshot, serviceTime: Histogram.Snapshot)
+ extends MetricGroupSnapshot {
+
+ type GroupSnapshotType = DiskMetricsSnapshot
+
+ def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = {
+ DiskMetricsSnapshot(reads.merge(that.reads, context), writes.merge(that.writes, context), queue.merge(that.queue, context), serviceTime.merge(that.serviceTime, context))
+ }
+
+ lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map(
+ Reads -> reads,
+ Writes -> writes,
+ Queue -> queue,
+ ServiceTime -> serviceTime)
+ }
+
+ val Factory = DiskMetricGroupFactory
+}
+
+case object DiskMetricGroupFactory extends MetricGroupFactory {
+
+ import DiskMetrics._
+
+ type GroupRecorder = DiskMetricsRecorder
+
+ def create(config: Config, system: ActorSystem): GroupRecorder = {
+ val settings = config.getConfig("precision.system.disk")
+
+ val readsDiskConfig = settings.getConfig("reads")
+ val writesDiskConfig = settings.getConfig("writes")
+ val queueDiskConfig = settings.getConfig("queue")
+ val serviceTimeDiskConfig = settings.getConfig("service-time")
+
+ new DiskMetricsRecorder(
+ Histogram.fromConfig(readsDiskConfig),
+ Histogram.fromConfig(writesDiskConfig),
+ Histogram.fromConfig(queueDiskConfig),
+ Histogram.fromConfig(serviceTimeDiskConfig))
+ }
+}
+
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala
index bc5fc724..5aa679c9 100644
--- a/kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala
@@ -20,7 +20,7 @@ import java.lang.management.GarbageCollectorMXBean
import akka.actor.ActorSystem
import com.typesafe.config.Config
import kamon.metric._
-import kamon.metric.instrument.{ Gauge, Histogram }
+import kamon.metric.instrument.Histogram
case class GCMetrics(name: String) extends MetricGroupIdentity {
val category = GCMetrics
@@ -32,7 +32,7 @@ object GCMetrics extends MetricGroupCategory {
case object CollectionCount extends MetricIdentity { val name = "collection-count" }
case object CollectionTime extends MetricIdentity { val name = "collection-time" }
- case class GCMetricRecorder(count: Gauge, time: Gauge)
+ case class GCMetricRecorder(count: Histogram, time: Histogram)
extends MetricGroupRecorder {
def collect(context: CollectionContext): MetricGroupSnapshot = {
@@ -71,8 +71,7 @@ case class GCMetricGroupFactory(gc: GarbageCollectorMXBean) extends MetricGroupF
val timeConfig = settings.getConfig("time")
new GCMetricRecorder(
- Gauge.fromConfig(countConfig, system)(() ⇒ gc.getCollectionCount),
- Gauge.fromConfig(timeConfig, system, Scale.Milli)(() ⇒ gc.getCollectionTime))
+ Histogram.fromConfig(countConfig),
+ Histogram.fromConfig(timeConfig))
}
-}
-
+} \ No newline at end of file
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 ac033fe2..5bba5bf6 100644
--- a/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala
@@ -29,9 +29,9 @@ case class HeapMetrics(name: String) extends MetricGroupIdentity {
object HeapMetrics extends MetricGroupCategory {
val name = "heap"
- case object Used extends MetricIdentity { val name = "used-heap" }
- case object Max extends MetricIdentity { val name = "max-heap" }
- case object Committed extends MetricIdentity { val name = "committed-heap" }
+ case object Used extends MetricIdentity { val name = "used" }
+ case object Max extends MetricIdentity { val name = "max" }
+ case object Committed extends MetricIdentity { val name = "committed" }
case class HeapMetricRecorder(used: Gauge, max: Gauge, committed: Gauge)
extends MetricGroupRecorder {
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala
new file mode 100644
index 00000000..cd196adf
--- /dev/null
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala
@@ -0,0 +1,80 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2014 the kamon project <http://kamon.io/>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ * =========================================================================================
+ */
+package kamon.metrics
+
+import akka.actor.ActorSystem
+import com.typesafe.config.Config
+import kamon.metric._
+import kamon.metric.instrument.Histogram
+
+case class LoadAverageMetrics(name: String) extends MetricGroupIdentity {
+ val category = LoadAverageMetrics
+}
+
+object LoadAverageMetrics extends MetricGroupCategory {
+ val name = "load-average"
+
+ case object OneMinute extends MetricIdentity { val name = "last-minute" }
+ case object FiveMinutes extends MetricIdentity { val name = "last-five-minutes" }
+ case object FifteenMinutes extends MetricIdentity { val name = "last-fifteen-minutes" }
+
+ case class LoadAverageMetricsRecorder(one: Histogram, five: Histogram, fifteen: Histogram)
+ extends MetricGroupRecorder {
+
+ def collect(context: CollectionContext): MetricGroupSnapshot = {
+ LoadAverageMetricsSnapshot(one.collect(context), five.collect(context), fifteen.collect(context))
+ }
+
+ def cleanup: Unit = {}
+ }
+
+ case class LoadAverageMetricsSnapshot(one: Histogram.Snapshot, five: Histogram.Snapshot, fifteen: Histogram.Snapshot)
+ extends MetricGroupSnapshot {
+
+ type GroupSnapshotType = LoadAverageMetricsSnapshot
+
+ def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = {
+ LoadAverageMetricsSnapshot(one.merge(that.one, context), five.merge(that.five, context), fifteen.merge(that.fifteen, context))
+ }
+
+ lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map(
+ OneMinute -> one,
+ FiveMinutes -> five,
+ FifteenMinutes -> fifteen)
+ }
+
+ val Factory = LoadAverageMetricGroupFactory
+}
+
+case object LoadAverageMetricGroupFactory extends MetricGroupFactory {
+
+ import LoadAverageMetrics._
+
+ type GroupRecorder = LoadAverageMetricsRecorder
+
+ def create(config: Config, system: ActorSystem): GroupRecorder = {
+ val settings = config.getConfig("precision.system.load-average")
+
+ val oneMinuteConfig = settings.getConfig("one")
+ val fiveMinutesConfig = settings.getConfig("five")
+ val fifteenMinutesConfig = settings.getConfig("fifteen")
+
+ new LoadAverageMetricsRecorder(
+ Histogram.fromConfig(oneMinuteConfig),
+ Histogram.fromConfig(fiveMinutesConfig),
+ Histogram.fromConfig(fifteenMinutesConfig))
+ }
+}
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala
new file mode 100644
index 00000000..c2b9f9af
--- /dev/null
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala
@@ -0,0 +1,86 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2014 the kamon project <http://kamon.io/>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ * =========================================================================================
+ */
+package kamon.metrics
+
+import java.lang.management.ManagementFactory
+
+import akka.actor.ActorSystem
+import com.typesafe.config.Config
+import kamon.metric._
+import kamon.metric.instrument.{ Gauge, Histogram }
+
+case class NonHeapMetrics(name: String) extends MetricGroupIdentity {
+ val category = NonHeapMetrics
+}
+
+object NonHeapMetrics extends MetricGroupCategory {
+ val name = "non-heap"
+
+ case object Used extends MetricIdentity { val name = "used" }
+ case object Max extends MetricIdentity { val name = "max" }
+ case object Committed extends MetricIdentity { val name = "committed" }
+
+ case class NonHeapMetricRecorder(used: Gauge, max: Gauge, committed: Gauge)
+ extends MetricGroupRecorder {
+
+ def collect(context: CollectionContext): MetricGroupSnapshot = {
+ NonHeapMetricSnapshot(used.collect(context), max.collect(context), committed.collect(context))
+ }
+
+ def cleanup: Unit = {}
+ }
+
+ case class NonHeapMetricSnapshot(used: Histogram.Snapshot, max: Histogram.Snapshot, committed: Histogram.Snapshot)
+ extends MetricGroupSnapshot {
+
+ type GroupSnapshotType = NonHeapMetricSnapshot
+
+ def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = {
+ NonHeapMetricSnapshot(used.merge(that.used, context), max.merge(that.max, context), committed.merge(that.committed, context))
+ }
+
+ lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map(
+ Used -> used,
+ Max -> max,
+ Committed -> committed)
+ }
+
+ val Factory = NonHeapMetricGroupFactory
+}
+
+case object NonHeapMetricGroupFactory extends MetricGroupFactory {
+
+ import NonHeapMetrics._
+ import kamon.system.SystemMetricsExtension._
+
+ def nonHeap = ManagementFactory.getMemoryMXBean.getNonHeapMemoryUsage
+
+ type GroupRecorder = NonHeapMetricRecorder
+
+ def create(config: Config, system: ActorSystem): GroupRecorder = {
+ val settings = config.getConfig("precision.jvm.non-heap")
+
+ val usedNonHeapConfig = settings.getConfig("used")
+ val maxNonHeapConfig = settings.getConfig("max")
+ val committedNonHeapConfig = settings.getConfig("committed")
+
+ new NonHeapMetricRecorder(
+ Gauge.fromConfig(usedNonHeapConfig, system, Scale.Mega)(() ⇒ toMB(nonHeap.getUsed)),
+ Gauge.fromConfig(maxNonHeapConfig, system, Scale.Mega)(() ⇒ toMB(nonHeap.getMax)),
+ Gauge.fromConfig(committedNonHeapConfig, system, Scale.Mega)(() ⇒ toMB(nonHeap.getCommitted)))
+ }
+}
+
diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala
new file mode 100644
index 00000000..fc039ffa
--- /dev/null
+++ b/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala
@@ -0,0 +1,85 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2014 the kamon project <http://kamon.io/>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ * =========================================================================================
+ */
+package kamon.metrics
+
+import java.lang.management.ManagementFactory
+
+import akka.actor.ActorSystem
+import com.typesafe.config.Config
+import kamon.metric._
+import kamon.metric.instrument.{ Gauge, Histogram }
+
+case class ThreadMetrics(name: String) extends MetricGroupIdentity {
+ val category = ThreadMetrics
+}
+
+object ThreadMetrics extends MetricGroupCategory {
+ val name = "thread"
+
+ case object Damon extends MetricIdentity { val name = "daemon-count" }
+ case object Count extends MetricIdentity { val name = "count" }
+ case object Peak extends MetricIdentity { val name = "peak-count" }
+
+ case class ThreadMetricRecorder(daemon: Gauge, count: Gauge, peak: Gauge)
+ extends MetricGroupRecorder {
+
+ def collect(context: CollectionContext): MetricGroupSnapshot = {
+ ThreadMetricSnapshot(daemon.collect(context), count.collect(context), peak.collect(context))
+ }
+
+ def cleanup: Unit = {}
+ }
+
+ case class ThreadMetricSnapshot(daemon: Histogram.Snapshot, count: Histogram.Snapshot, peak: Histogram.Snapshot)
+ extends MetricGroupSnapshot {
+
+ type GroupSnapshotType = ThreadMetricSnapshot
+
+ def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = {
+ ThreadMetricSnapshot(daemon.merge(that.daemon, context), count.merge(that.count, context), peak.merge(that.peak, context))
+ }
+
+ lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map(
+ Damon -> daemon,
+ Count -> count,
+ Peak -> peak)
+ }
+
+ val Factory = ThreadMetricGroupFactory
+}
+
+case object ThreadMetricGroupFactory extends MetricGroupFactory {
+
+ import ThreadMetrics._
+
+ def threads = ManagementFactory.getThreadMXBean
+
+ type GroupRecorder = ThreadMetricRecorder
+
+ def create(config: Config, system: ActorSystem): GroupRecorder = {
+ val settings = config.getConfig("precision.jvm.thread")
+
+ val daemonThreadConfig = settings.getConfig("daemon")
+ val countThreadsConfig = settings.getConfig("count")
+ val peakThreadsConfig = settings.getConfig("peak")
+
+ new ThreadMetricRecorder(
+ Gauge.fromConfig(daemonThreadConfig, system)(() ⇒ threads.getDaemonThreadCount.toLong),
+ Gauge.fromConfig(countThreadsConfig, system)(() ⇒ threads.getThreadCount.toLong),
+ Gauge.fromConfig(peakThreadsConfig, system)(() ⇒ threads.getPeakThreadCount.toLong))
+ }
+}
+