wood burning stoves 2.0*
The moose likes Performance and the fly likes how JaMon is helpful for web application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "how JaMon is helpful for web application?" Watch "how JaMon is helpful for web application?" New topic
Author

how JaMon is helpful for web application?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I understood little bit of JaMon. But I am highly confused how it will monitor web applications/user interaction???

Say, I have a developed web application, have many classes and each class has many methods. Now, all classes doesn't necessarily implements interface so how JaMon will work in this case???

If at all, suppose all classes implements interface then do I need to write a separate program -- get object of those classes through monitor() method and call different-different methods -- to monitor performance???

If so, then where I measured, how much time it took when user performed any operation in my web application???

Hope my all points are clear.

Please comments.

Thanks.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
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 ]

http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
After reading from that tutorial, I added start() and stop() method in the beginning and end respectively.

But I am getting this error, I know this is not related to JaMon but not able to find root cause...



Where could be the problem???

This is my JSP:


Thanks.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Just to add in previous post, I have jamon-2.2.jar file into classpath and I am able to run JaMon code from a Java class.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
It looks like a classpath problem. Make sure that the jamon jar file is in the appropriate directory for your servlet runner/app servers jar files. Other than that it should work.
Mike Hayes
Greenhorn

Joined: Aug 26, 2008
Posts: 4
In case anyone else has a similar problem...

I had this problem with Jamon 2.7 on GlassFish V2. It turns out that the jamonapi jar file doesn't seem to be included with the Jamon war file.
Perhaps there's something in the instructions that I missed, or something went awry during deployment.

In any case, I resolved the problem by copying the jamon-2.7.jar file to the exploded war file 'lib' directory.
Mike Hayes
Greenhorn

Joined: Aug 26, 2008
Posts: 4
Posted too soon.

Add the jamon jar file to the appservers classpath - do not put the jar in multiple places. Otherwise you won't get all the monitors you expect.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how JaMon is helpful for web application?
 
Similar Threads
Jamon + Spring
Question regarding JAmon
JAMon 2.1 and Monitoring SQL
Measuring performance of a Application
JAMon 2.1 and Monitoring SQL/JDBC