Report GC metrics.
This commit is contained in:
parent
8a595ed77a
commit
95428ab8b0
|
@ -87,6 +87,8 @@ import org.whispersystems.textsecuregcm.mappers.RateLimitExceededExceptionMapper
|
|||
import org.whispersystems.textsecuregcm.metrics.CpuUsageGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.FileDescriptorGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.FreeMemoryGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionCountGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.GarbageCollectionTimeGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsApplicationEventListener;
|
||||
import org.whispersystems.textsecuregcm.metrics.NetworkReceivedGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.NetworkSentGauge;
|
||||
|
@ -447,6 +449,8 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
|||
environment.metrics().register(name(NetworkSentGauge.class, "bytes_sent"), new NetworkSentGauge());
|
||||
environment.metrics().register(name(NetworkReceivedGauge.class, "bytes_received"), new NetworkReceivedGauge());
|
||||
environment.metrics().register(name(FileDescriptorGauge.class, "fd_count"), new FileDescriptorGauge());
|
||||
environment.metrics().register(name(GarbageCollectionCountGauge.class, "gc_count"), new GarbageCollectionCountGauge());
|
||||
environment.metrics().register(name(GarbageCollectionTimeGauge.class, "gc_time"), new GarbageCollectionTimeGauge());
|
||||
}
|
||||
|
||||
private void registerExceptionMappers(Environment environment, WebSocketEnvironment<Account> webSocketEnvironment, WebSocketEnvironment<Account> provisioningEnvironment) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue