do not count a Monitor, eg on error

  • Jan van Oosterom

    If an error happens in out system, the monitored code is much faster. That messes up our stats.
    Is it save -not- to call Monitor.stop on error? 

  • Steve Souza

    Steve Souza - 2010-08-06

    It is safe in that no memory resources will be consumed or lost.  jamon however tracks the number of active monitors of the current type though.   This number is decremented at stop time and so won't be decremented properly.

    One other way to keep stats only when there is no error using add.

    For example instead of start you could do this (i may not be calling the right method names as I am doing it from memory.

    long startTime=System.timeInMills();

    If there is no error then do this.
    long endTime=System.timeInMills();

    MonitorFactory.add("label", "ms.", endtime-startTime);

    You could hide this logic in your own monitor class.

    Also instead of calling System.timeInMillis() directly you could call.

    Monitor mon=MonitorFactory.start();

    and in case of no error call

    // don't recall if stop is required to be called or not.

    MonitorFactory.add("label", "ms.", mon.getAvg());

  • Steve Souza

    Steve Souza - 2011-07-18

    There will be a mon.skip() in the next version to solve this problem.

  • Steve Souza

    Steve Souza - 2011-07-24

    JAMon 2.71 was released today with this fix in it.

    JAMon 2.71 is a minor release that adds a few features that users requested after version 2.7 (Thanks for patiently waiting!). JAMon still requires JDK 1.4 or higher (with a couple exceptions referenced below). If version 2.7 is working for you and you don't want the features below then this is not a required upgrade. To use 2.71 you must install the new jar (jamon-2.71.jar), and if you are using using JAMon war to view the JAMon stats then you must also install the new war.

    See this link for more information:
    To download:


Log in to post a comment.