diff options
Diffstat (limited to 'kamon-system-metrics/src/main/scala/kamon/metrics')
12 files changed, 0 insertions, 1013 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 deleted file mode 100644 index 20789039..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/CPUMetrics.scala +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ========================================================================================= - * 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 CPUMetrics(name: String) extends MetricGroupIdentity { - val category = CPUMetrics -} - -object CPUMetrics extends MetricGroupCategory { - val name = "cpu" - - case object User extends MetricIdentity { val name = "user" } - case object System extends MetricIdentity { val name = "system" } - case object Wait extends MetricIdentity { val name = "wait" } - case object Idle extends MetricIdentity { val name = "idle" } - case object Stolen extends MetricIdentity { val name = "stolen" } - - case class CPUMetricRecorder(user: Histogram, system: Histogram, cpuWait: Histogram, idle: Histogram, stolen: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - CPUMetricSnapshot(user.collect(context), system.collect(context), cpuWait.collect(context), idle.collect(context), stolen.collect(context)) - } - - def cleanup: Unit = {} - } - - case class CPUMetricSnapshot(user: Histogram.Snapshot, system: Histogram.Snapshot, cpuWait: Histogram.Snapshot, idle: Histogram.Snapshot, stolen: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = CPUMetricSnapshot - - def merge(that: CPUMetricSnapshot, context: CollectionContext): GroupSnapshotType = { - CPUMetricSnapshot(user.merge(that.user, context), system.merge(that.system, context), cpuWait.merge(that.cpuWait, context), idle.merge(that.idle, context), stolen.merge(that.stolen, context)) - } - - lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - User -> user, - System -> system, - Wait -> cpuWait, - Idle -> idle, - Stolen -> stolen) - } - - val Factory = CPUMetricGroupFactory -} - -case object CPUMetricGroupFactory extends MetricGroupFactory { - - import CPUMetrics._ - - type GroupRecorder = CPUMetricRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.system.cpu") - - val userConfig = settings.getConfig("user") - val systemConfig = settings.getConfig("system") - val cpuWaitConfig = settings.getConfig("wait") - val idleConfig = settings.getConfig("idle") - val stolenConfig = settings.getConfig("stolen") - - new CPUMetricRecorder( - Histogram.fromConfig(userConfig), - Histogram.fromConfig(systemConfig), - Histogram.fromConfig(cpuWaitConfig), - Histogram.fromConfig(idleConfig), - Histogram.fromConfig(stolenConfig)) - } -} diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala deleted file mode 100644 index 1e3bee27..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/ClassLoadingMetrics.scala +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ========================================================================================= - * 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/ContextSwitchesMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ContextSwitchesMetrics.scala deleted file mode 100644 index 86aeabce..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/ContextSwitchesMetrics.scala +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ========================================================================================= - * 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 ContextSwitchesMetrics(name: String) extends MetricGroupIdentity { - val category = ContextSwitchesMetrics -} - -object ContextSwitchesMetrics extends MetricGroupCategory { - val name = "context-switches" - - case object PerProcessVoluntary extends MetricIdentity { val name = "per-process-voluntary" } - case object PerProcessNonVoluntary extends MetricIdentity { val name = "per-process-non-voluntary" } - case object Global extends MetricIdentity { val name = "global" } - - case class ContextSwitchesMetricsRecorder(perProcessVoluntary: Histogram, perProcessNonVoluntary: Histogram, global: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - ContextSwitchesMetricsSnapshot(perProcessVoluntary.collect(context), perProcessNonVoluntary.collect(context), global.collect(context)) - } - - def cleanup: Unit = {} - } - - case class ContextSwitchesMetricsSnapshot(perProcessVoluntary: Histogram.Snapshot, perProcessNonVoluntary: Histogram.Snapshot, global: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = ContextSwitchesMetricsSnapshot - - def merge(that: ContextSwitchesMetricsSnapshot, context: CollectionContext): GroupSnapshotType = { - ContextSwitchesMetricsSnapshot(perProcessVoluntary.merge(that.perProcessVoluntary, context), perProcessVoluntary.merge(that.perProcessVoluntary, context), global.merge(that.global, context)) - } - - lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - PerProcessVoluntary -> perProcessVoluntary, - PerProcessNonVoluntary -> perProcessNonVoluntary, - Global -> global) - } - - val Factory = ContextSwitchesMetricGroupFactory -} - -case object ContextSwitchesMetricGroupFactory extends MetricGroupFactory { - import ContextSwitchesMetrics._ - - type GroupRecorder = ContextSwitchesMetricsRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.system.context-switches") - - val perProcessVoluntary = settings.getConfig("per-process-voluntary") - val perProcessNonVoluntary = settings.getConfig("per-process-non-voluntary") - val global = settings.getConfig("global") - - new ContextSwitchesMetricsRecorder( - Histogram.fromConfig(perProcessVoluntary), - Histogram.fromConfig(perProcessNonVoluntary), - Histogram.fromConfig(global)) - } -} - diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala deleted file mode 100644 index eeb6002b..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/DiskMetrics.scala +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ========================================================================================= - * 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 deleted file mode 100644 index 5aa679c9..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/GCMetrics.scala +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ========================================================================================= - * 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.GarbageCollectorMXBean - -import akka.actor.ActorSystem -import com.typesafe.config.Config -import kamon.metric._ -import kamon.metric.instrument.Histogram - -case class GCMetrics(name: String) extends MetricGroupIdentity { - val category = GCMetrics -} - -object GCMetrics extends MetricGroupCategory { - val name = "gc" - - case object CollectionCount extends MetricIdentity { val name = "collection-count" } - case object CollectionTime extends MetricIdentity { val name = "collection-time" } - - case class GCMetricRecorder(count: Histogram, time: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - GCMetricSnapshot(count.collect(context), time.collect(context)) - } - - def cleanup: Unit = {} - } - - case class GCMetricSnapshot(count: Histogram.Snapshot, time: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = GCMetricSnapshot - - def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = { - GCMetricSnapshot(count.merge(that.count, context), time.merge(that.time, context)) - } - - lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - CollectionCount -> count, - CollectionTime -> time) - } - - def Factory(gc: GarbageCollectorMXBean) = GCMetricGroupFactory(gc) -} - -case class GCMetricGroupFactory(gc: GarbageCollectorMXBean) extends MetricGroupFactory { - import GCMetrics._ - - type GroupRecorder = GCMetricRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.jvm.gc") - - val countConfig = settings.getConfig("count") - val timeConfig = settings.getConfig("time") - - new GCMetricRecorder( - 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 deleted file mode 100644 index 5bba5bf6..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/HeapMetrics.scala +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ========================================================================================= - * 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 HeapMetrics(name: String) extends MetricGroupIdentity { - val category = HeapMetrics -} - -object HeapMetrics extends MetricGroupCategory { - val name = "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 { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - HeapMetricSnapshot(used.collect(context), max.collect(context), committed.collect(context)) - } - - def cleanup: Unit = {} - } - - case class HeapMetricSnapshot(used: Histogram.Snapshot, max: Histogram.Snapshot, committed: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = HeapMetricSnapshot - - def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = { - HeapMetricSnapshot(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 = HeapMetricGroupFactory -} - -case object HeapMetricGroupFactory extends MetricGroupFactory { - - import HeapMetrics._ - import kamon.system.SystemMetricsExtension._ - - def heap = ManagementFactory.getMemoryMXBean.getHeapMemoryUsage - - type GroupRecorder = HeapMetricRecorder - - 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))) - } - -} - diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala deleted file mode 100644 index cd196adf..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/LoadAverageMetrics.scala +++ /dev/null @@ -1,80 +0,0 @@ -/* - * ========================================================================================= - * 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/MemoryMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/MemoryMetrics.scala deleted file mode 100644 index 14051427..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/MemoryMetrics.scala +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ========================================================================================= - * 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 MemoryMetrics(name: String) extends MetricGroupIdentity { - val category = MemoryMetrics -} - -object MemoryMetrics extends MetricGroupCategory { - val name = "memory" - - case object Used extends MetricIdentity { val name = "used" } - case object Free extends MetricIdentity { val name = "free" } - case object Buffer extends MetricIdentity { val name = "buffer" } - case object Cache extends MetricIdentity { val name = "cache" } - case object SwapUsed extends MetricIdentity { val name = "swap-used" } - case object SwapFree extends MetricIdentity { val name = "swap-free" } - - case class MemoryMetricRecorder(used: Histogram, free: Histogram, buffer: Histogram, cache: Histogram, swapUsed: Histogram, swapFree: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - MemoryMetricSnapshot(used.collect(context), free.collect(context), buffer.collect(context), cache.collect(context), swapUsed.collect(context), swapFree.collect(context)) - } - - def cleanup: Unit = {} - } - - case class MemoryMetricSnapshot(used: Histogram.Snapshot, free: Histogram.Snapshot, buffer: Histogram.Snapshot, cache: Histogram.Snapshot, swapUsed: Histogram.Snapshot, swapFree: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = MemoryMetricSnapshot - - def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = { - MemoryMetricSnapshot(used.merge(that.used, context), free.merge(that.free, context), buffer.merge(that.buffer, context), cache.merge(that.cache, context), swapUsed.merge(that.swapUsed, context), swapFree.merge(that.swapFree, context)) - } - - lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - Used -> used, - Free -> free, - Buffer -> buffer, - Cache -> cache, - SwapUsed -> swapUsed, - SwapFree -> swapFree) - } - - val Factory = MemoryMetricGroupFactory -} - -case object MemoryMetricGroupFactory extends MetricGroupFactory { - - import MemoryMetrics._ - - type GroupRecorder = MemoryMetricRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.system.memory") - - val usedConfig = settings.getConfig("used") - val freeConfig = settings.getConfig("free") - val bufferConfig = settings.getConfig("buffer") - val cacheConfig = settings.getConfig("cache") - val swapUsedConfig = settings.getConfig("swap-used") - val swapFreeConfig = settings.getConfig("swap-free") - - new MemoryMetricRecorder( - Histogram.fromConfig(usedConfig, Scale.Mega), - Histogram.fromConfig(freeConfig, Scale.Mega), - Histogram.fromConfig(swapUsedConfig, Scale.Mega), - Histogram.fromConfig(swapFreeConfig, Scale.Mega), - Histogram.fromConfig(bufferConfig, Scale.Mega), - Histogram.fromConfig(cacheConfig, Scale.Mega)) - } -}
\ No newline at end of file diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala deleted file mode 100644 index d8a38f6d..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ========================================================================================= - * 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 NetworkMetrics(name: String) extends MetricGroupIdentity { - val category = NetworkMetrics -} - -object NetworkMetrics extends MetricGroupCategory { - val name = "network" - - case object RxBytes extends MetricIdentity { val name = "rx-bytes" } - case object TxBytes extends MetricIdentity { val name = "tx-bytes" } - case object RxErrors extends MetricIdentity { val name = "rx-errors" } - case object TxErrors extends MetricIdentity { val name = "tx-errors" } - case object RxDropped extends MetricIdentity { val name = "rx-dropped" } - case object TxDropped extends MetricIdentity { val name = "tx-dropped" } - - case class NetworkMetricRecorder(rxBytes: Histogram, txBytes: Histogram, rxErrors: Histogram, txErrors: Histogram, rxDropped: Histogram, txDropped: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - NetworkMetricSnapshot(rxBytes.collect(context), txBytes.collect(context), rxErrors.collect(context), txErrors.collect(context), rxDropped.collect(context), txDropped.collect(context)) - } - - def cleanup: Unit = {} - } - - case class NetworkMetricSnapshot(rxBytes: Histogram.Snapshot, txBytes: Histogram.Snapshot, rxErrors: Histogram.Snapshot, txErrors: Histogram.Snapshot, rxDropped: Histogram.Snapshot, txDropped: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = NetworkMetricSnapshot - - def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = { - NetworkMetricSnapshot(rxBytes.merge(that.rxBytes, context), txBytes.merge(that.txBytes, context), rxErrors.merge(that.rxErrors, context), txErrors.merge(that.txErrors, context), rxDropped.merge(that.rxDropped, context), txDropped.merge(that.txDropped, context)) - } - - val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - RxBytes -> rxBytes, - TxBytes -> txBytes, - RxErrors -> rxErrors, - TxErrors -> txErrors, - RxDropped -> rxDropped, - TxDropped -> txDropped) - } - - val Factory = NetworkMetricGroupFactory -} - -case object NetworkMetricGroupFactory extends MetricGroupFactory { - import NetworkMetrics._ - - type GroupRecorder = NetworkMetricRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.system.network") - - val rxBytesConfig = settings.getConfig("rx-bytes") - val txBytesConfig = settings.getConfig("tx-bytes") - val rxErrorsConfig = settings.getConfig("rx-errors") - val txErrorsConfig = settings.getConfig("tx-errors") - val rxDroppedConfig = settings.getConfig("rx-dropped") - val txDroppedConfig = settings.getConfig("tx-dropped") - - new NetworkMetricRecorder( - Histogram.fromConfig(rxBytesConfig, Scale.Kilo), - Histogram.fromConfig(txBytesConfig, Scale.Kilo), - Histogram.fromConfig(rxErrorsConfig), - Histogram.fromConfig(txErrorsConfig), - Histogram.fromConfig(rxDroppedConfig), - Histogram.fromConfig(txDroppedConfig)) - } -}
\ No newline at end of file diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala deleted file mode 100644 index c2b9f9af..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/NonHeapMetrics.scala +++ /dev/null @@ -1,86 +0,0 @@ -/* - * ========================================================================================= - * 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/ProcessCPUMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ProcessCPUMetrics.scala deleted file mode 100644 index ebd79d48..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/ProcessCPUMetrics.scala +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ========================================================================================= - * 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 ProcessCPUMetrics(name: String) extends MetricGroupIdentity { - val category = ProcessCPUMetrics -} - -object ProcessCPUMetrics extends MetricGroupCategory { - val name = "proc-cpu" - - case object CpuPercent extends MetricIdentity { val name = "cpu-percentage" } - case object TotalProcessTime extends MetricIdentity { val name = "total-process-time" } - - case class ProcessCPUMetricsRecorder(cpuPercent: Histogram, totalProcessTime: Histogram) - extends MetricGroupRecorder { - - def collect(context: CollectionContext): MetricGroupSnapshot = { - ProcessCPUMetricsSnapshot(cpuPercent.collect(context), totalProcessTime.collect(context)) - } - - def cleanup: Unit = {} - } - - case class ProcessCPUMetricsSnapshot(cpuPercent: Histogram.Snapshot, totalProcessTime: Histogram.Snapshot) - extends MetricGroupSnapshot { - - type GroupSnapshotType = ProcessCPUMetricsSnapshot - - def merge(that: ProcessCPUMetricsSnapshot, context: CollectionContext): GroupSnapshotType = { - ProcessCPUMetricsSnapshot(cpuPercent.merge(that.cpuPercent, context), totalProcessTime.merge(that.totalProcessTime, context)) - } - - lazy val metrics: Map[MetricIdentity, MetricSnapshot] = Map( - CpuPercent -> cpuPercent, - TotalProcessTime -> totalProcessTime) - } - - val Factory = ProcessCPUMetricGroupFactory -} - -case object ProcessCPUMetricGroupFactory extends MetricGroupFactory { - import ProcessCPUMetrics._ - - type GroupRecorder = ProcessCPUMetricsRecorder - - def create(config: Config, system: ActorSystem): GroupRecorder = { - val settings = config.getConfig("precision.system.process-cpu") - - val cpuPercentageConfig = settings.getConfig("cpu-percentage") - val totalProcessTimeConfig = settings.getConfig("total-process-time") - - new ProcessCPUMetricsRecorder( - Histogram.fromConfig(cpuPercentageConfig), - Histogram.fromConfig(totalProcessTimeConfig)) - } -} - diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala deleted file mode 100644 index fc039ffa..00000000 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/ThreadMetrics.scala +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ========================================================================================= - * 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)) - } -} - |