blob: d9379738f5f467d2ab2b2674a3deaea70076e029 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package kamon.system.jmx
import java.lang.management.ManagementFactory
import kamon.metric.GenericEntityRecorder
import kamon.metric.instrument.{ Memory, InstrumentFactory }
class ClassLoadingMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) {
val classLoadingBean = ManagementFactory.getClassLoadingMXBean
gauge("classes-loaded", Memory.Bytes, () ⇒ {
classLoadingBean.getTotalLoadedClassCount
})
gauge("classes-unloaded", Memory.Bytes, () ⇒ {
classLoadingBean.getUnloadedClassCount
})
gauge("classes-currently-loaded", Memory.Bytes, () ⇒ {
classLoadingBean.getLoadedClassCount.toLong
})
}
object ClassLoadingMetrics extends JmxSystemMetricRecorderCompanion("class-loading") {
def apply(instrumentFactory: InstrumentFactory): ClassLoadingMetrics =
new ClassLoadingMetrics(instrumentFactory)
}
|