Monitoring Interfaces

Monitoring Interfaces

Interface monitoring is useful, but if it is possible it is better to use JAMon and capabilities of Spring, AOP, EJB's to monitor your interfaces.

With one line of code you can monitor ANY java interface. Any interface means you can easily monitor standard java interfaces such as JDBC, open source interfaces such as the log4J appender interface or your own custom interfaces. To monitor an interface you simply have to call the following JAMon method:

import com.jamonapi.proxy.*;

// The MyObject() class has to implement MyInterface for monitoring to work.
MyInterface myObject = (MyInterface) MonProxyFactory.monitor(new MyObject());
myObject.myMethod();// method call will be monitored with JAMon.

That's it! Simply make method calls to myObject as you normally would, and the calls will be monitored. (Note it is best to hide the use of JAMon in a monitoring class of your own creation).

Any methods on the interface will be timed and any exceptions they throw will be tracked. The following jamonadmin.jsp screenshot shows methods called against JDBC interfaces. Any methods you call against your custom interfaces should look similar.

Method Calls (JAMon Summary Statistics)

JAMon summary statistics such as hits, time statistics (avg,total,min,max), concurrency statistics and more will be tracked for all of methods of the interface. The JAMon label for monitoring of interface method calls always begins with: MonProxy-Interface. JAMon statistics are viewable via the jamonadmin.jsp page in jamon.war (discussed later). The following is an example of the JAMon label associated with the Connection classes close() method. Note the JAMon label consists of the concrete class as well as the interfaces method signature.

MonProxy-Interface (class=org.hsqldb.jdbcConnection): public abstract void java.sql.Connection.close() throws java.sql.SQLException

Interface summary statistics are viewable via jamonadmin.jsp.

Exceptions (JAMon Summary Statistics)

JAMon summary statistics are kept whenever a monitored interface throws an Exception.

Any time a monitored interface throws an exception several JAMon summary records will be added. JAMon labels for Exception summary statistics begin with: MonProxy-Exception. These summary statistics allow developers to easily see how many Exceptions the application has thrown. For each exception that the interface throws the the following three types of JAMon summary labels will appear in the report.

Exception summary statistics are viewable via jamonadmin.jsp.

Exceptions (Exception Details)

The details of the N most recent Exceptions thrown by monitored interfaces (including the stack trace) are kept in a rolling buffer and viewable via exceptions.jsp. The exception buffer size is configurable via the web page, and defaults to the most recent 50 exceptions. Typically such stack trace information is only available in a log which a developer might not have access to and even if they do the log must be parsed to view the stack traces.

Each row in the report represents a recent Exception thrown from a monitored inteface. Each row contains the following columns

Exception details statistics are viewable via exceptions.jsp.

Note on Exception Monitoring

One nice thing about Exception monitoring is that even when developers gobble/hide exceptions in the following manner they will show up in the JAMonAdmin report and exception detail report. The following example is taken from the JAMon demo.

  // Throw an exception and show that it is also monitored in jamonadmin.jsp and exceptions.jsp
  // Note also even though the catch block is empty it will show up in these pages.
  try {
   // get a query to throw an Exception.  If enabled will show in jamon report and sql details.
   st.executeQuery("select * from i_do_not_exist");
  } catch (Exception e) {} Logo