Excalibur Instrument - InstrumentsInstrumentsInstruments are the actual hooks used by a component to make profiling or instrumentation information available to the outside world. Instruments are created by a component during their initialization phase and then referenced throughout the life of the component. The Instruments should be created whether the component is registered with an InstrumentManager or not. This removes the necessity for the component to do anything special if not registered. The Instruments themselves are designed to be extremely lightweight. In cases where an InstrumentManager is not present, or where it is present but output is not currently being collected, the Instrument effectively becomes a noop. There are currently two types of Instruments available for use by components. So far they have proven to be enough to profile any type of quantitative information. The first is the CounterInstrument. Counters are used to, well, count the number of times that something happens. They can be used to keep track of the number of times a method is called, a resource is accessed, etc. The CounterInstrument provides two methods. The first, increment(), which ups the counter by 1. And the second, instrument( count ), which accepts any positive integer. The later method can be used in cases where increment would normally have to be called a large number of times. For example, the number of iterations in a sort algorithm. The second type of Instrument is the ValueInstrument. ValueInstruments are used to track quantities over time. Examples are the size of a pool, the current memory usage of the JVM, etc. ValueInstruments provide a single method, setValue( value ). |