NSAmelchev commented on a change in pull request #7446: IGNITE-12464 : Service metrics URL: https://github.com/apache/ignite/pull/7446#discussion_r400438477
########## File path: modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java ########## @@ -1801,4 +1842,176 @@ 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) + .filter(mtd -> !isMetricIgnoredFor(mtd.getDeclaringClass())) + .forEach(mtd -> { + // All metrics for current service. + Map<String, MethodHistogramHolder> srvcHistograms = + invocationHistograms.computeIfAbsent(srvcName, name -> new HashMap<>(1)); Review comment: `ConcurrentHashMap` should be used. Otherwise, it's possible to get the exception here: ``` java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode at java.util.HashMap$TreeNode.moveRootToFront(HashMap.java:1835) at java.util.HashMap$TreeNode.treeify(HashMap.java:1951) at java.util.HashMap.treeifyBin(HashMap.java:772) at java.util.HashMap.computeIfAbsent(HashMap.java:1140) ``` ---------------------------------------------------------------- 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