codahale/metrics — pull request #393 by Arvoreen (2013-05-03 18:03:42+00:00)
Title: Allow metrics registry to be serializable

I had a use case where I wanted to collect all my metrics into a centralized location. Ideally, I want to eventually be able to 'merge' selected metrics together from multiple instances. Towards that end, I needed a MetricRegistry to be serializable, as that seemed to be the most straightforward way to transfer what I wanted around...serialize my MetricsRegistry and send it... In order to accomplish this, I did the following:

1) Have com.codahale.metrics.Metric extend Serializable
2) Introduce a new marker interface, com.codahale.metrics.NoCopyMetric
3) Create custom serialization logic in MetricsRegistry that will
serialize all metrics that do NOT have the NoCopyMetric marker
4) Add some other NoCopy* signatures
5) Modify some of the pre-creatable metrics that could not be serialized
to be marked as NoCopy