Since a servlet will be running for an extended period of time, it may be useful to record or accumulate statistics throughout it's life, possibly for use in profiling. The statistics facility allows a no-hassle approach to keeping statistics. Each statistic can contain a number of elements, such as counters, lists or other statistics. Methods on each statistic such as incStat, and addStat allow easy incrementing of variables and adding objects to a list. Actions can also be bound to each statistics' values. For example, you may wish an email to be dispatched if the "FatalError" counter is incremented. Statistics must be registered before they can be used. This, however, raises the likelihood some code may attempt to access a statistic which is not registered, and throw null-pointer exception. Using a technique similar to the null object pattern, accesses to non-existent statistics are safe and effectively ignored. If a request to the StatisticsManager requests a non-existent statistic, a DummyStat is returned, which effectively ignores all requests. This allows you to safely increment and access statistics inside your code, without fear that the statistic was never registered. Each statistic can render itself to HTML, allowing easy retrieval of values stored inside of statistic. Values stored inside each statistic, are not stored to a database by default, and will be reset when the servlet is restarted.

A number of statistics are included with apollo, and are generally wise to activate.

ServletStat -- Keeps track of number of requests, start date and other servlet centric data
GZIP -- Keeps track of the effectiveness of the GZIP compression and CPU utilization
UserException -- Keeps track of (user) exceptions traveling to the top of the apollo tree
NodeStat -- Monitors effective load distribution across jini nodes