You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/08/20 09:05:07 UTC

[GitHub] [cassandra] blerer commented on a change in pull request #1146: CASSANDRA-16859 - allow blocking IPs from updating metrics about traffic

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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org