Copilot commented on code in PR #3019:
URL: https://github.com/apache/celeborn/pull/3019#discussion_r2230455546


##########
common/src/main/java/org/apache/celeborn/common/network/util/NettyMemoryMetrics.java:
##########
@@ -136,6 +136,14 @@ private void registerMetrics() {
             MetricRegistry.name(metricPrefix, "chunkSize"),
             labels,
             pooledAllocatorMetric::chunkSize);
+        source.addGauge(
+            MetricRegistry.name(metricPrefix, "pinnedHeapMemory"),
+            labels,
+            () -> ((PooledByteBufAllocator) allocator).pinnedHeapMemory());
+        source.addGauge(
+            MetricRegistry.name(metricPrefix, "pinnedDirectMemory"),
+            labels,
+            () -> ((PooledByteBufAllocator) allocator).pinnedDirectMemory());

Review Comment:
   The cast to PooledByteBufAllocator is unsafe. If the allocator is not an 
instance of PooledByteBufAllocator, this will throw a ClassCastException at 
runtime. Consider adding an instanceof check before casting or handling 
non-pooled allocators gracefully.
   ```suggestion
               pooledAllocatorMetric::pinnedHeapMemory);
           source.addGauge(
               MetricRegistry.name(metricPrefix, "pinnedDirectMemory"),
               labels,
               pooledAllocatorMetric::pinnedDirectMemory);
   ```



-- 
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]

Reply via email to