Fix some metrics names/types.
This commit is contained in:
parent
c5147e0c68
commit
691ab3080d
|
@ -42,7 +42,6 @@ import io.dropwizard.setup.Bootstrap;
|
|||
import io.dropwizard.setup.Environment;
|
||||
import io.micrometer.core.instrument.Clock;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||
import io.micrometer.wavefront.WavefrontConfig;
|
||||
import io.micrometer.wavefront.WavefrontMeterRegistry;
|
||||
|
@ -85,11 +84,11 @@ import org.whispersystems.textsecuregcm.mappers.DeviceLimitExceededExceptionMapp
|
|||
import org.whispersystems.textsecuregcm.mappers.IOExceptionMapper;
|
||||
import org.whispersystems.textsecuregcm.mappers.InvalidWebsocketAddressExceptionMapper;
|
||||
import org.whispersystems.textsecuregcm.mappers.RateLimitExceededExceptionMapper;
|
||||
import org.whispersystems.textsecuregcm.metrics.BufferPoolGauges;
|
||||
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.GarbageCollectionGauges;
|
||||
import org.whispersystems.textsecuregcm.metrics.MaxFileDescriptorGauge;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsApplicationEventListener;
|
||||
import org.whispersystems.textsecuregcm.metrics.NetworkReceivedGauge;
|
||||
|
@ -163,8 +162,6 @@ import org.whispersystems.websocket.setup.WebSocketEnvironment;
|
|||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import java.lang.management.BufferPoolMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.security.Security;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
|
@ -453,17 +450,10 @@ 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());
|
||||
environment.metrics().register(name(MaxFileDescriptorGauge.class, "max_fd_count"), new MaxFileDescriptorGauge());
|
||||
|
||||
for (final BufferPoolMXBean bufferPoolMXBean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) {
|
||||
final List<Tag> tags = List.of(Tag.of("name", bufferPoolMXBean.getName()));
|
||||
|
||||
Metrics.gauge(name(BufferPoolMXBean.class, "count"), tags, bufferPoolMXBean, BufferPoolMXBean::getCount);
|
||||
Metrics.gauge(name(BufferPoolMXBean.class, "memory_used"), tags, bufferPoolMXBean, BufferPoolMXBean::getMemoryUsed);
|
||||
Metrics.gauge(name(BufferPoolMXBean.class, "total_capacity"), tags, bufferPoolMXBean, BufferPoolMXBean::getTotalCapacity);
|
||||
}
|
||||
BufferPoolGauges.registerMetrics();
|
||||
GarbageCollectionGauges.registerMetrics();
|
||||
}
|
||||
|
||||
private void registerExceptionMappers(Environment environment, WebSocketEnvironment<Account> webSocketEnvironment, WebSocketEnvironment<Account> provisioningEnvironment) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue