Copilot commented on code in PR #11445:
URL: https://github.com/apache/ozone/pull/11445#discussion_r4220959496


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMetrics.java:
##########
@@ -167,13 +167,13 @@ public class OMMetrics implements OmMetadataReaderMetrics 
{
   private @Metric MutableCounterLong numCancelSnapshotDiffFails;
   private @Metric MutableCounterLong numListSnapshotDiffJobFails;
 
-  private @Metric MutableCounterLong numSnapshotActive;
-  private @Metric MutableCounterLong numSnapshotDeleted;
+  private @Metric MutableGaugeLong numSnapshotActive;
+  private @Metric MutableGaugeLong numSnapshotDeleted;
 
   // Number of tenant operations attempted
   private @Metric MutableCounterLong numTenantOps;
   // Metrics for a total number of tenants

Review Comment:
   These metrics are now gauges specifically because they can decrease. 
Consider adding a brief comment directly above `numSnapshotActive`, 
`numSnapshotDeleted`, and `numTenants` indicating they represent *current* 
counts (not totals) and may go up/down. This helps prevent future regressions 
where a decreasing metric is mistakenly converted back to a counter.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetricsSetters.java:
##########
@@ -55,4 +55,23 @@ public void testSetTotals() {
     assertGauge("NumDirs", 4L, rb);
     assertGauge("NumFiles", 5L, rb);
   }
+
+  @Test
+  public void testSnapshotAndTenantCounts() {
+    metrics = OMMetrics.create(new OzoneConfiguration());
+    metrics.setNumSnapshotActive(5);
+    metrics.setNumSnapshotActive(3);

Review Comment:
   This test reassigns `metrics` by calling `OMMetrics.create(...)` inside the 
test. If this class already creates/registers an `OMMetrics` instance in a 
setup method, this pattern can leave a previously-registered metrics source 
around and make tests order-dependent or flaky (duplicate registration / stale 
values). Prefer reusing the instance created by the test setup, or explicitly 
unregister/shutdown the previous metrics source before re-creating it in the 
test.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to