codahale/metrics — pull request #256 by joshdevins (2012-06-29 10:05:19+00:00)
Title: Metrics event listeners

This PR adds event listeners to metrics state change events. This can drive realtime metrics sending to external aggregators like StatsD.

Change summary:
* added ObservableMetric base class which manages listeners of a metric
* need to pass MetricName into Metric constructors so that listeners know the name
* added MetricListenersRegistry to handle registration of listeners based on a MetricPredicate
* added MetricListener and metric specific interfaces like CounterListener
* added MetricListenersRegistry as a listener to MetricsRegistry in the Metrics convenience class

It is assumed that all listener implementations are non-blocking (and thread safe) as no timeouts or such are performed in order to keep things simple.

Open to suggestions on any changes or improvements.