Vladsz83 commented on a change in pull request #7446: IGNITE-12464 : Service metrics URL: https://github.com/apache/ignite/pull/7446#discussion_r400813600
########## 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)); + + // Histograms for this method name. + MethodHistogramHolder mtdHistograms = + srvcHistograms.computeIfAbsent(mtd.getName(), mdtName -> new MethodHistogramHolder()); Review comment: @NSAmelchev , the problem is: `interface A { void foo(); } interface B extends A { @Override void foo(); } static class C implements Service, B { @Override public void foo() { System.err.println("foo"); } ... } @Test public void test() throws Exception { Method methodA = A.class.getMethod("foo"); Method methodB = B.class.getMethod("foo"); Method methodC = C.class.getMethod("foo"); assertEquals(methodA, methodB); assertEquals(methodA, methodC); assertEquals(methodB, methodA); assertEquals(methodB, methodC); assertEquals(methodC, methodA); assertEquals(methodC, methodB); }` They are not equal. And yes, significant invocation boost. If we keep direct link to not-overloaded method, we avoid: 1) Creation new Method() (`getMethod()` always create new one) 2) Creation new Object[] when calling `Method.getParameterTypes()` to identify method. 3) We do not search overloaded methods map at all. We get method by it name. ---------------------------------------------------------------- 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