ivandasch commented on a change in pull request #7446: IGNITE-12464 : Service 
metrics
URL: https://github.com/apache/ignite/pull/7446#discussion_r400943267
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java
 ##########
 @@ -1801,4 +1842,178 @@ private boolean enterBusy() {
     private void leaveBusy() {
         opsLock.readLock().unlock();
     }
+
+    /**
+     * Registers metrics to measure durations of service methods.
+     *
+     * @param srvc Service for invocations measurement.
+     * @param srvcName Name of {@code srvc}.
+     */
+    private void registerMetrics(Service srvc, String srvcName) {
+        
getInterfaces(srvc.getClass()).stream().map(Class::getMethods).flatMap(Arrays::stream)
 
 Review comment:
   ```
   for (Class<?> iface : getInterfaces(srvc.getClass())) {
       for (Method mtd : iface.getMethods()) {
           if (!isMetricIgnoredFor(mtd.getDeclaringClass()))
               continue;
   
           Map<String, MethodHistogramHolder> srvcHistograms =
               invocationHistograms.computeIfAbsent(srvcName, name -> new 
HashMap<>(1));
   
           synchronized (srvcHistograms) {
               srvcHistograms.compute(mtd.getName(), (mtdName, hldr) -> {
                   MethodHistogramHolder hldr0 = hldr == null ? new 
MethodHistogramHolder() : hldr;
                   
                   hldr0.addIfAbsent(mtd, () -> createHistogram(srvcName, mtd));
                   
                   return hldr0;
               });
           }
       }
   ```
    I suppose, that this is a way more readable. And thread safe. By the way, 
`MethodHistogramHolder#addIfAbsent` may not be synchronized, if the method is 
implemented this way.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to