The following diagram shows the custom PMI environment:
The following steps are required to instrument an application using Custom
PMI:
- Define a Stats module template. An XML document is used to define a set
of statistics for a given application component. This XML document is used
as a template to create the PMI data. The XML document should follow the DTD
com/ibm/websphere/pmi/xml/stats.dtd
- Create a Stats object using StatsFactory. The StatsFactory is used to
create an instance (StatsInstance) or group (StatsGroup) of the Stats template.
The StatsInstance object represents a single instance of the Stats template
and contains all the statistics defined in the template. The StatsGroup is
a logical collection of similar Stats instances. Custom PMI provides the flexibility
to arrange the groups and instances in a tree structure.

The
illustration above shows two instances of stock applications that are grouped
under a StockAppStats group. The StockAppStats group can have multiple Stock
applications, and each Stock application instance can have a StockBroker group.
In this case, the StockAppStats group aggregates the statistics from StockApp1
and StockApp2, and the StockBroker group aggregates the statistics from all
the StockBroker instances in their respective groups.
- Instrument the application by updating the Stats object. To instrument,
the application should call the Stats module for PMI service to maintain
the raw counts. For example, to instrument the number of sells processed
by the Stock application, create a Stats module with a statistic of type
CountStatistic. When a sell transaction is processed, increment the number
of sells statistic by calling: NumSellsCountStatistic.increment ();