• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how JaMon is helpful for web application?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic