mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 02:08:04 +01:00
Report GC metrics.
This commit is contained in:
committed by
Jon Chambers
parent
8a595ed77a
commit
95428ab8b0
@@ -0,0 +1,19 @@
|
||||
package org.whispersystems.textsecuregcm.metrics;
|
||||
|
||||
import com.codahale.metrics.Gauge;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
abstract class AbstractGarbageCollectionGauge implements Gauge<Long> {
|
||||
|
||||
private final GarbageCollectorMXBean garbageCollectorMXBean;
|
||||
|
||||
public AbstractGarbageCollectionGauge() {
|
||||
this.garbageCollectorMXBean = (GarbageCollectorMXBean)ManagementFactory.getGarbageCollectorMXBeans();
|
||||
}
|
||||
|
||||
protected GarbageCollectorMXBean getGarbageCollectorMXBean() {
|
||||
return garbageCollectorMXBean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.whispersystems.textsecuregcm.metrics;
|
||||
|
||||
/**
|
||||
* A gauge that reports the total number of collections that have occurred in this JVM's lifetime.
|
||||
*/
|
||||
public class GarbageCollectionCountGauge extends AbstractGarbageCollectionGauge {
|
||||
|
||||
@Override
|
||||
public Long getValue() {
|
||||
return getGarbageCollectorMXBean().getCollectionCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.whispersystems.textsecuregcm.metrics;
|
||||
|
||||
/**
|
||||
* A gauge that reports the cumulative amount of time (in milliseconds) spent on garbage collection.
|
||||
*/
|
||||
public class GarbageCollectionTimeGauge extends AbstractGarbageCollectionGauge {
|
||||
|
||||
@Override
|
||||
public Long getValue() {
|
||||
return getGarbageCollectorMXBean().getCollectionTime();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user