use of io.netty.buffer.ByteBufAllocatorMetric in project reactor-netty by reactor.
the class ByteBufAllocatorMetrics method registerMetrics.
void registerMetrics(String allocType, ByteBufAllocatorMetric metrics, ByteBufAllocator alloc) {
MapUtils.computeIfAbsent(cache, metrics.hashCode() + "", key -> {
Tags tags = Tags.of(ID.getKey(), key, TYPE.getKey(), allocType);
Gauge.builder(USED_HEAP_MEMORY.getName(), metrics, ByteBufAllocatorMetric::usedHeapMemory).tags(tags).register(REGISTRY);
Gauge.builder(USED_DIRECT_MEMORY.getName(), metrics, ByteBufAllocatorMetric::usedDirectMemory).tags(tags).register(REGISTRY);
if (metrics instanceof PooledByteBufAllocatorMetric) {
PooledByteBufAllocatorMetric pooledMetrics = (PooledByteBufAllocatorMetric) metrics;
PooledByteBufAllocator pooledAlloc = (PooledByteBufAllocator) alloc;
Gauge.builder(HEAP_ARENAS.getName(), pooledMetrics, PooledByteBufAllocatorMetric::numHeapArenas).tags(tags).register(REGISTRY);
Gauge.builder(DIRECT_ARENAS.getName(), pooledMetrics, PooledByteBufAllocatorMetric::numDirectArenas).tags(tags).register(REGISTRY);
Gauge.builder(THREAD_LOCAL_CACHES.getName(), pooledMetrics, PooledByteBufAllocatorMetric::numThreadLocalCaches).tags(tags).register(REGISTRY);
Gauge.builder(SMALL_CACHE_SIZE.getName(), pooledMetrics, PooledByteBufAllocatorMetric::smallCacheSize).tags(tags).register(REGISTRY);
Gauge.builder(NORMAL_CACHE_SIZE.getName(), pooledMetrics, PooledByteBufAllocatorMetric::normalCacheSize).tags(tags).register(REGISTRY);
Gauge.builder(CHUNK_SIZE.getName(), pooledMetrics, PooledByteBufAllocatorMetric::chunkSize).tags(tags).register(REGISTRY);
Gauge.builder(ACTIVE_HEAP_MEMORY.getName(), pooledAlloc, PooledByteBufAllocator::pinnedHeapMemory).tags(tags).register(REGISTRY);
Gauge.builder(ACTIVE_DIRECT_MEMORY.getName(), pooledAlloc, PooledByteBufAllocator::pinnedDirectMemory).tags(tags).register(REGISTRY);
}
return metrics;
});
}
use of io.netty.buffer.ByteBufAllocatorMetric in project ratpack by ratpack.
the class UnpooledByteBufAllocatorMetricSet method initMetrics.
private void initMetrics() {
final ByteBufAllocatorMetric metric = unpooledByteBufAllocator.metric();
metrics.put("usedDirectMemory", (Gauge<Long>) () -> metric.usedDirectMemory());
metrics.put("usedHeapMemory", (Gauge<Long>) () -> metric.usedHeapMemory());
}
use of io.netty.buffer.ByteBufAllocatorMetric in project zuul by Netflix.
the class Server method start.
public void start() {
serverGroup = new ServerGroup("Salamander", eventLoopConfig.acceptorCount(), eventLoopConfig.eventLoopCount(), eventLoopGroupMetrics);
serverGroup.initializeTransport();
try {
List<ChannelFuture> allBindFutures = new ArrayList<>(addressesToInitializers.size());
// Setup each of the channel initializers on requested ports.
for (Map.Entry<NamedSocketAddress, ? extends ChannelInitializer<?>> entry : addressesToInitializers.entrySet()) {
NamedSocketAddress requestedNamedAddr = entry.getKey();
ChannelFuture nettyServerFuture = setupServerBootstrap(requestedNamedAddr, entry.getValue());
Channel chan = nettyServerFuture.channel();
addressesToChannels.put(requestedNamedAddr.withNewSocket(chan.localAddress()), chan);
allBindFutures.add(nettyServerFuture);
}
// Add metrics to monitor that allocator's memory usage.
if (!allBindFutures.isEmpty()) {
ByteBufAllocator alloc = allBindFutures.get(0).channel().alloc();
if (alloc instanceof ByteBufAllocatorMetricProvider) {
ByteBufAllocatorMetric metrics = ((ByteBufAllocatorMetricProvider) alloc).metric();
PolledMeter.using(registry).withId(registry.createId("zuul.nettybuffermem.live", "type", "heap")).monitorValue(metrics, ByteBufAllocatorMetric::usedHeapMemory);
PolledMeter.using(registry).withId(registry.createId("zuul.nettybuffermem.live", "type", "direct")).monitorValue(metrics, ByteBufAllocatorMetric::usedDirectMemory);
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
Aggregations