mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 06:28:01 +01:00
Fix some metrics names/types.
This commit is contained in:
committed by
Jon Chambers
parent
c5147e0c68
commit
691ab3080d
@@ -1,19 +0,0 @@
|
||||
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,25 @@
|
||||
package org.whispersystems.textsecuregcm.metrics;
|
||||
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
|
||||
import java.lang.management.BufferPoolMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
|
||||
import static com.codahale.metrics.MetricRegistry.name;
|
||||
|
||||
public class BufferPoolGauges {
|
||||
|
||||
private BufferPoolGauges() {}
|
||||
|
||||
public static void registerMetrics() {
|
||||
for (final BufferPoolMXBean bufferPoolMXBean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) {
|
||||
final List<Tag> tags = List.of(Tag.of("name", bufferPoolMXBean.getName()));
|
||||
|
||||
Metrics.gauge(name(BufferPoolGauges.class, "count"), tags, bufferPoolMXBean, BufferPoolMXBean::getCount);
|
||||
Metrics.gauge(name(BufferPoolGauges.class, "memory_used"), tags, bufferPoolMXBean, BufferPoolMXBean::getMemoryUsed);
|
||||
Metrics.gauge(name(BufferPoolGauges.class, "total_capacity"), tags, bufferPoolMXBean, BufferPoolMXBean::getTotalCapacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
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,24 @@
|
||||
package org.whispersystems.textsecuregcm.metrics;
|
||||
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
|
||||
import static com.codahale.metrics.MetricRegistry.name;
|
||||
|
||||
public class GarbageCollectionGauges {
|
||||
|
||||
private GarbageCollectionGauges() {}
|
||||
|
||||
public static void registerMetrics() {
|
||||
for (final GarbageCollectorMXBean garbageCollectorMXBean : ManagementFactory.getGarbageCollectorMXBeans()) {
|
||||
final List<Tag> tags = List.of(Tag.of("name", garbageCollectorMXBean.getName()));
|
||||
|
||||
Metrics.gauge(name(GarbageCollectionGauges.class, "collection_count"), tags, garbageCollectorMXBean, GarbageCollectorMXBean::getCollectionCount);
|
||||
Metrics.gauge(name(GarbageCollectionGauges.class, "collection_time"), tags, garbageCollectorMXBean, GarbageCollectorMXBean::getCollectionTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
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