On 28 February 2013 07:03, Ian Boston <[email protected]> wrote:
>
> How do you all feel about a service or a singleton covering counters, set
> values and possibly running mean?. I am less keen on anything that's
> expensive to record as impact on the runtime must be close to zero.
ie: something like [1]. It was a lot more sophisticated initially, but
it was slower, created more GC traffic and in the end I thought, whats
the point, so I cut it back to really simple again.
To use.
import org.apache.sling.commons.monitor.Statistics;
Statistics statistics = StatisticsFactory.instance();
statistics.get("counter").incrementAndGet();
statistics.get("setvalue").set(System.currentTimeMillis());
or to avoid the get completely.
private static final AtomicLong counter =
StatisticsFactory.instance().get("counter");
counter.incrementAndGet();
The output of the servlet is of the form:
{
"_timenanos": 1362121529334796000,
"counter": 1,
"ObservationDispatcher.backlog": 101,
"ObservationDispatcher.added": 12191812191,
"ObservationDispatcher.removed": 12191812090
}
I thought about Statistics as a OSGI service, but decided not to to
avoid additional bindings. As a singleton only an import is needed.
WDYT, usable, or is JMX beans in each bundle going to be the way ?
Ian
1 http://svn.apache.org/repos/asf/sling/whiteboard/ieb/monitor/
>
> Ian