blerer commented on a change in pull request #1146:
URL: https://github.com/apache/cassandra/pull/1146#discussion_r692786887



##########
File path: 
test/distributed/org/apache/cassandra/distributed/impl/InstanceMetrics.java
##########
@@ -63,15 +79,32 @@ public long getCounter(String name)
             if (filter.test(e.getKey()))
                 values.put(e.getKey(), e.getValue().getCount());
         }
+        for (Map.Entry<String, Meter> e : 
metricsRegistry.getMeters().entrySet())

Review comment:
       We can probably use a similar approach to what I suggested for 
`getCounter()`

##########
File path: 
test/distributed/org/apache/cassandra/distributed/impl/InstanceMetrics.java
##########
@@ -45,16 +45,32 @@
         this.metricsRegistry = metricsRegistry;
     }
 
+    @Override
     public List<String> getNames()
     {
         return new ArrayList<>(metricsRegistry.getNames());
     }
 
+    @Override
     public long getCounter(String name)
     {
-        return metricsRegistry.getCounters().get(name).getCount();

Review comment:
       I have not tried but I think that we should be able to simplify the code 
by doing:
   ```
   Metric metric = metricsRegistry.getMetrics().get(name);
   if (metric instanceof Counting)
       return ((Counting) metric).getCount(); 
   // If the metric is not found or does not expose a getCount method
   return 0;
   ```
   
    




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