pan3793 commented on code in PR #3043:
URL: https://github.com/apache/celeborn/pull/3043#discussion_r1900158336
##########
common/src/main/java/org/apache/celeborn/common/network/util/NettyMemoryMetrics.java:
##########
@@ -69,71 +67,87 @@ public class NettyMemoryMetrics {
}
public NettyMemoryMetrics(
- PooledByteBufAllocator pooledAllocator,
+ ByteBufAllocator allocator,
String metricPrefix,
boolean verboseMetricsEnabled,
AbstractSource source,
Map<String, String> labels) {
- this.pooledAllocator = pooledAllocator;
+ this.allocator = allocator;
this.metricPrefix = metricPrefix;
this.verboseMetricsEnabled = verboseMetricsEnabled;
this.source = source;
this.labels = labels;
- registerMetrics(this.pooledAllocator);
+ registerMetrics();
}
- private void registerMetrics(PooledByteBufAllocator allocator) {
- PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric();
-
+ private void registerMetrics() {
// Register general metrics.
if (source != null) {
- logger.debug("setup netty metrics");
- source.addGauge(
- MetricRegistry.name(metricPrefix, "usedHeapMemory"),
- labels,
- pooledAllocatorMetric::usedHeapMemory);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "usedDirectMemory"),
- labels,
- pooledAllocatorMetric::usedDirectMemory);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "numHeapArenas"),
- labels,
- pooledAllocatorMetric::numHeapArenas);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "numDirectArenas"),
- labels,
- pooledAllocatorMetric::numDirectArenas);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "tinyCacheSize"),
- labels,
- pooledAllocatorMetric::tinyCacheSize);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "smallCacheSize"),
- labels,
- pooledAllocatorMetric::smallCacheSize);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "normalCacheSize"),
- labels,
- pooledAllocatorMetric::normalCacheSize);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "numThreadLocalCaches"),
- labels,
- pooledAllocatorMetric::numThreadLocalCaches);
- source.addGauge(
- MetricRegistry.name(metricPrefix, "chunkSize"), labels,
pooledAllocatorMetric::chunkSize);
- if (verboseMetricsEnabled) {
- int directArenaIndex = 0;
- for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) {
- registerArenaMetric(metric, "directArena" + directArenaIndex);
- directArenaIndex++;
- }
+ if (allocator instanceof UnpooledByteBufAllocator) {
+ logger.debug("Setup netty metrics for UnpooledByteBufAllocator");
+ ByteBufAllocatorMetric unpooledMetric = ((UnpooledByteBufAllocator)
allocator).metric();
+ source.addGauge(
+ MetricRegistry.name(metricPrefix, "usedHeapMemory"),
+ labels,
+ unpooledMetric::usedHeapMemory);
+ source.addGauge(
+ MetricRegistry.name(metricPrefix, "usedDirectMemory"),
+ labels,
+ unpooledMetric::usedDirectMemory);
Review Comment:
UnpooledByteBufAllocator only supports these two metrics
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]