|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmonit.Monitoring
public final class Monitoring
Monitoring is a convenience entry point in the jMonit API. It handles a default Repository and defines static methods for accessing monitors.
The add(String, long)
method is designed to easily add any numeric
value to the specified monitor.
public String callMySaopService( Sring message ) { long bytes = message.getBytes().length; Monitoring.add( "mySaopService.sent", bytes ); String reply = service.call( message ); bytes = reply.getBytes().length; Monitoring.add( "mySaopService.received", bytes ); return reply; }
The start(..)
methods can be used to quickly create a Probe
and monitor time consumed in a block of code. Never forget to stop the
returned Probe ! A try / finally block is the safer way to ensure this with
fiew impact on performances :
public void myBusinessMethod() { Probe probe = Monitoring.start( "myBusinessMethod" ); try { // Some bunsiness code you want to monitor here... } finally { probe.stop(); } }
Method Summary | |
---|---|
static void |
add(java.lang.String name,
long value)
Add data to a monitor. |
static Monitor |
getMonitor(java.lang.String name)
Get an existing monitor or creates it. |
static Repository |
getRepository()
|
static void |
setRepository(Repository repository)
Replace the repository by a custom one. |
static Stopwatch |
start(java.lang.String name)
Start a new Stopwatch for the monitor 'name'. |
static Stopwatch |
start(java.lang.String name,
java.lang.String... tags)
Start a new Stopwatch for the monitor 'name', and apply the tags to the monitor. |
static Monitor |
tag(java.lang.String name,
java.lang.String tag)
Apply the specified tag to the specified monitor |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void add(java.lang.String name, long value)
name
- The monitor namevalue
- The value to be added (positive or negative)public static Monitor getMonitor(java.lang.String name)
name
- The monitor name
public static Repository getRepository()
public static void setRepository(Repository repository)
repository
- the repository to setpublic static Stopwatch start(java.lang.String name)
name
- The monitor name
public static Stopwatch start(java.lang.String name, java.lang.String... tags)
name
- The monitor nametags
- The tags to apply on the monitor
public static Monitor tag(java.lang.String name, java.lang.String tag)
name
- monitor nametag
- tag
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |