Skip to content

Commit 7a6ddd7

Browse files
Bue-von-honikhoon
andauthored
Automatically register the metics of PooledByteBufAllocator.DEFAULT (#5916)
Motivation: Add metrics related to PooledByteBufAllocator that is already exposed by the netty. Modifications: - `NettyAllocatorMetrics` are registered when MoreMeterBinders is initialized. Result: - Fixes #2633 - Armeria now automatically registers the metics of `PooledByteBufAllocator.DEFAULT`. --------- Co-authored-by: Ikhun Um <ih.pert@gmail.com>
1 parent 9bb5215 commit 7a6ddd7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/main/java/com/linecorp/armeria/common/metric/MoreMeterBinders.java

+9
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,26 @@
2525

2626
import com.google.common.collect.ImmutableList;
2727

28+
import com.linecorp.armeria.common.Flags;
2829
import com.linecorp.armeria.common.annotation.UnstableApi;
2930
import com.linecorp.armeria.internal.common.util.CertificateUtil;
3031

3132
import io.micrometer.core.instrument.binder.MeterBinder;
33+
import io.micrometer.core.instrument.binder.netty4.NettyAllocatorMetrics;
34+
import io.netty.buffer.PooledByteBufAllocator;
3235
import io.netty.channel.EventLoopGroup;
3336

3437
/**
3538
* Provides useful {@link MeterBinder}s to monitor various Armeria components.
3639
*/
3740
public final class MoreMeterBinders {
3841

42+
static {
43+
// Bind the default Netty allocator metrics to the default MeterRegistry.
44+
new NettyAllocatorMetrics(PooledByteBufAllocator.DEFAULT)
45+
.bindTo(Flags.meterRegistry());
46+
}
47+
3948
/**
4049
* Returns a new {@link MeterBinder} to observe Netty's {@link EventLoopGroup}s. The following stats are
4150
* currently exported per registered {@link MeterIdPrefix}.

0 commit comments

Comments
 (0)