0

i'm currently replacing javaSimon with javaMelody: we use the StopWatch from JavaSimon to monitor the time used to execute the core functions. This needs to be replaced by using JavaMelody. So when we enable the monitoring for core functions. JavaMelody can report the performance of the core functions.

any idea about the stopWatch in JavaMelody Please ?

Amirak
  • 63
  • 1
  • 8

1 Answers1

0

If what you want to monitor is the execution of methods, you can do that using Spring or EJB/CDI or simple java interfaces. The results will be displayed in the statistics of the reports.

Or if what you want to monitor is just the execution of some pieces of codes, you can create methods and monitor them. For example:

Runnable runnable = new Runnable() {
   @Override
   public void run() {
      // your piece of code
   }
};
runnable = MonitoringProxy.createProxy(runnable, "name you want in the statistics");
runnable.run();

And to make the monitoring of pieces of code simpler, I have just added a new simple API in javamelody and so you could do now:

try (Stopwatch stopwatch = new Stopwatch("name you want in the statistics")) {
      // your piece of code
}

The results will also be displayed in the statistics of the reports. For that last one, you will need a snapshot build to be released in 1.77.

evernat
  • 1,713
  • 13
  • 18
  • for monitoring the execution of some pieces of codes, using StopWatch, do i need only to add the new snapshot build in my libs folder? And what about MonitoringProxy and Stopwatch, they are two ways to handle that or they are complementary? many thanks – Amirak Mar 06 '19 at 09:07
  • Yes, replace your current javamelody-core-1.xx.y.jar file by the new build javamelody-core-1.77.0-SNAPSHOT.jar file, probably in your libs folder. And Stopwatch is a new simpler way of doing the same thing with MonitoringProxy. It's either one or the other to monitor pieces of code. – evernat Mar 07 '19 at 20:56