Instrumentation

The org.jmonit package provides all required classes to instrument you application code.

The Monitor class is used by application to expose state to the monitoring infrastructure. A Monitor accepts new datas via the add(long) method. jMonit does not know the unit used by such data, so be aware not to mix inconsistent values.

A monitor is identified by a name, that MUST be unique in the application. A recommended usage is to use the full qualified class name + some local name to identify a monitor. For example, the monitor "com.mycompany.ws.MyServiceEndPoint.doSomeBusiness()" could be used to monitor the MyService web service endpoint "doSomeBusiness" method execution. To also monitor SOAP message weight, you can create another monitor "com.mycompany.ws.MyServiceEndPoint.doSomeBusiness()-soap" .

The Monitoring class is a utility class to acces jMonit classes. It provides finders methods to retrieve a monitor by name, tag it, or create a new Probe for performance computation. All Monitors are attched to a repository. You can acces the repository from the Monitoring class, or set a new instance if you want to use a custom repository implementation.

The monitor can be tagged. A tag is used by the application to group monitors and refine the type of data that is monitored. Tags can reflect data type and units, component that uses the monitor, or whatever you need. For example, a monitor attached to a web service endpoint to gather incomming messages size can be tagged "soap", "ws", "bytes" and "received".

Performance is a main part of monitoring. For this purpose, jMonit provides the dedicated Probe class. A new Probe is created by calling Probe.start( monitor ) . The convenience static method Monitoring.start( name ) can be used to get a starter probe in one line. The probe will compute elapsed time until it gets stopped, after the monitored code fragmentends. Using a probe automatically tags the monitor as "perf".