Skip to content

Commit

Permalink
Automatically register the metics of PooledByteBufAllocator.DEFAULT (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
Bue-von-hon and ikhoon authored Nov 25, 2024
1 parent 9bb5215 commit 7a6ddd7
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@

import com.google.common.collect.ImmutableList;

import com.linecorp.armeria.common.Flags;
import com.linecorp.armeria.common.annotation.UnstableApi;
import com.linecorp.armeria.internal.common.util.CertificateUtil;

import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.binder.netty4.NettyAllocatorMetrics;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.EventLoopGroup;

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

static {
// Bind the default Netty allocator metrics to the default MeterRegistry.
new NettyAllocatorMetrics(PooledByteBufAllocator.DEFAULT)
.bindTo(Flags.meterRegistry());
}

/**
* Returns a new {@link MeterBinder} to observe Netty's {@link EventLoopGroup}s. The following stats are
* currently exported per registered {@link MeterIdPrefix}.
Expand Down

0 comments on commit 7a6ddd7

Please sign in to comment.