blob: a96b5319f92c64444234c5e0422aa672a566ccd5 (
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
29
|
package kamon.system.jmx
import java.lang.management.ManagementFactory
import kamon.metric.GenericEntityRecorder
import kamon.metric.instrument.{ Memory, InstrumentFactory }
class HeapMemoryMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) {
val memoryBean = ManagementFactory.getMemoryMXBean
def nonHeapUsage = memoryBean.getHeapMemoryUsage
gauge("heap-used", Memory.Bytes, () ⇒ {
nonHeapUsage.getUsed
})
gauge("heap-max", Memory.Bytes, () ⇒ {
nonHeapUsage.getMax
})
gauge("heap-committed", Memory.Bytes, () ⇒ {
nonHeapUsage.getCommitted
})
}
object HeapMemoryMetrics extends JmxSystemMetricRecorderCompanion("heap-memory") {
def apply(instrumentFactory: InstrumentFactory): HeapMemoryMetrics =
new HeapMemoryMetrics(instrumentFactory)
}
|