Skip to content

Commit

Permalink
Update to vertx ByteBuf allocator going impl
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Oct 29, 2024
1 parent e614cb6 commit 5bd6d3d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/io/vertx/micrometer/impl/VertxMetricsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import io.micrometer.core.instrument.binder.netty4.NettyEventExecutorMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.core.instrument.binder.system.UptimeMetrics;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufAllocatorMetricProvider;
import io.netty.buffer.PooledByteBufAllocator;
import io.vertx.core.Vertx;
import io.vertx.core.internal.buffer.VertxByteBufAllocator;
import io.vertx.core.datagram.DatagramSocketOptions;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.internal.VertxInternal;
import io.vertx.core.internal.buffer.BufferInternal;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetServerOptions;
import io.vertx.core.net.SocketAddress;
Expand Down Expand Up @@ -91,11 +93,13 @@ public void init() {
addMeterBinder(new UptimeMetrics());
}
if (bindNettyMetrics) {
if (VertxByteBufAllocator.UNPOOLED_ALLOCATOR instanceof ByteBufAllocatorMetricProvider) {
addMeterBinder(new NettyAllocatorMetrics((ByteBufAllocatorMetricProvider) VertxByteBufAllocator.UNPOOLED_ALLOCATOR));
ByteBufAllocator allocator = BufferInternal.buffer().getByteBuf().alloc();
if (allocator instanceof ByteBufAllocatorMetricProvider) {
addMeterBinder(new NettyAllocatorMetrics((ByteBufAllocatorMetricProvider) allocator));
}
if (VertxByteBufAllocator.POOLED_ALLOCATOR instanceof ByteBufAllocatorMetricProvider) {
addMeterBinder(new NettyAllocatorMetrics((ByteBufAllocatorMetricProvider) VertxByteBufAllocator.POOLED_ALLOCATOR));
allocator = PooledByteBufAllocator.DEFAULT;
if (allocator != null) {
addMeterBinder(new NettyAllocatorMetrics((ByteBufAllocatorMetricProvider) allocator));
}
}
}
Expand Down

0 comments on commit 5bd6d3d

Please sign in to comment.