To answer your questions, a brief summary of jamon will help.
1) JAMon aggregates a number associated with a String/label. The more common use is to monitor execution time. Every time the 'start' method is called with the same label/string the following are tracked:hits, time stats (avg/min/max/std dev), concurrency stats, and more.
The data is viewable via the jamon web viewer.
It works like this:
Monitor mon=MonitorFactory.start("myHomePage.jsp");
..code..
mon.stop();
2) You can also aggregate any number (besides time) with the add method. You simply provide the label, units and value.
// this value will be aggregated with previous values that were called with the same label and units.
MonitorFactory.add("filesize","MB",.5);
MonitorFactory.add("purchases","$",125);
3) You can put the above methods in your code, however,
JAMon also comes with a servlet filter and jdbc driver that require no application code changes. For the servlet filter you simply add a few items into your web.xml. The servlet filter will track page level statistics (equivalent to calling Monitor mon=MonitorFactory.start(pageName))
You can also use the jamon jdbc proxy driver. This driver will record performance statistics for any SQL issued by the driver (It does more than this, but this should give you the idea). The jamon proxy driver replaces values from the sql with '?' in the case of Statement objects, and for PreparedStatement leaves the '?' in. So in effect something like the following is executed by the driver: Monitor mon=MonitorFactory.start("select fname, lname from mytable where ssn=?")
So no matter how many times the above query is executed with different values for ssn, there will only be one row in the jamon report.
4)
You can also monitor ANY java interface easily by using the following syntax: (assumes MyImplementation, and OtherObj are implementations of their respective interfaces)
MyInterface myObj=(MyInterface) MonProxyFactory.monitor(new MyImplementation());
OtherInterface otherObj=(OtherInterface) MonProxyFactory.monitor(new OtherObj());
To answer your question jamon can't directly monitor all classes in your app (nor do i think this is necessary). AOP can do such things though. Spring has a jamon interceptor that does just this.
Look at the links below to see more details. The javaranch performance faq below is a good start.
[ September 07, 2006: Message edited by: steve souza ]
[ September 08, 2006: Message edited by: steve souza ]