mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 11:26:47 +00:00
Use micrometer's netty metrics
This commit is contained in:
1 parent
c5ae3963b5
commit
848c457bbe
3 files changed
+14
-9
No files matched your search
+7
@@ -5,6 +5,8 @@
|
||||
package org.whispersystems.textsecuregcm.grpc.net;
|
||||
|
||||
import io.dropwizard.lifecycle.Managed;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.binder.netty4.NettyEventExecutorMetrics;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,11 @@ public class ManagedEventLoopGroup<T extends EventLoopGroup> implements Managed
|
||||
this.eventLoopGroup = eventLoopGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
new NettyEventExecutorMetrics(eventLoopGroup).bindTo(Metrics.globalRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
this.eventLoopGroup.shutdownGracefully().await();
|
||||
|
||||
@@ -95,15 +95,6 @@ public class OmnibusH2Server implements Managed {
|
||||
logger.warn("No SSL configuration provided for OmnibusH2Server, serving h2c");
|
||||
}
|
||||
|
||||
if (ByteBufAllocator.DEFAULT instanceof ByteBufAllocatorMetricProvider alloc) {
|
||||
Metrics.gauge(MetricsUtil.name(OmnibusH2Server.class, "nettyUsedDirectMemory"),
|
||||
alloc,
|
||||
allocator -> allocator.metric().usedDirectMemory());
|
||||
Metrics.gauge(MetricsUtil.name(OmnibusH2Server.class, "nettyUsedHeapMemory"),
|
||||
alloc,
|
||||
allocator -> allocator.metric().usedHeapMemory());
|
||||
}
|
||||
|
||||
final ServerBootstrap bootstrap = new ServerBootstrap()
|
||||
.group(nioEventLoopGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
|
||||
@@ -14,11 +14,14 @@ import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics;
|
||||
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
|
||||
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
|
||||
import io.micrometer.core.instrument.binder.netty4.NettyAllocatorMetrics;
|
||||
import io.micrometer.core.instrument.binder.system.FileDescriptorMetrics;
|
||||
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
||||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||
import io.micrometer.registry.otlp.OtlpMeterRegistry;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.ByteBufAllocatorMetricProvider;
|
||||
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;
|
||||
import io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
@@ -171,6 +174,10 @@ public class MetricsUtil {
|
||||
new JvmMemoryMetrics().bindTo(Metrics.globalRegistry);
|
||||
new JvmThreadMetrics().bindTo(Metrics.globalRegistry);
|
||||
|
||||
if (ByteBufAllocator.DEFAULT instanceof ByteBufAllocatorMetricProvider alloc) {
|
||||
new NettyAllocatorMetrics(alloc).bindTo(Metrics.globalRegistry);
|
||||
}
|
||||
|
||||
GarbageCollectionGauges.registerMetrics();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user