Sometimes we can have a code where we have some method which calls a bunch of internal methods one by one. Like in the example below:
public interface Foo { public void methodA(); public void methodB(); public void methodA1(); public void methodA2(); } public class Bar implements Foo { public void methodA() { methodA1(); methodA2(); } public void methodB() { } }
If we want to monitor the particular class with the Java Melody it’s enough to add annotation @MonitoredWithSpring to the interface. But then we will have monitoring details for the call of method Foo.methodA() which is called from external (ie. called by service), but no details for the internal method calls (methodA1() and methodA2()). It doesn’t work even if we try to annotate methods.
But there is a way to have it covered by Java Melody reports. There should be construction like below, which works perfectly.
public class Bar implements Foo { @Autowired private Foo myself; public void methodA() { myself.methodA1(); myself.methodA2(); } public void methodB() { } }