addthis/metrics-reporter-config — pull request #13 by tomvandenberge (2014-09-28 17:42:19+00:00)
Title: Allow configuration of any type of metrics reporter

I wanted to use metrics-reporter-config with a metrics reporter that is not (currently) supported. It turned out that this is not possible to do without modifying the code. The 5 metrics reporters that are currently supported are hard-wired into the code. Adding support for another reporter would require adding another piece of code for that reporter.

I found a quite simple way to allow configuration of any type of metrics reporter, without having to modify the code. The basic idea is to eliminate the compile-time dependencies on the reporters, and turn them into runtime dependencies. In the yaml file, it looks like this:

```
reporters:
-
!!com.addthis.metrics.reporter.config.CsvReporterConfig
outdir: '/tmp/metrics/csv-dir'
period: 2
timeunit: 'SECONDS'
```

So instead of the currently hard-coded collection of reporters (`csv`, `console`, `ganglia`, `graphite` and `riemann`), you can configure any type of reporter by listing it under `reporters`. The only additional requirement is that a yaml tag is added with the fully qualified class name of the reporter.

The reporters are only required to implement the (new) interface `com.addthis.metrics.reporter.config.ConfiguredReporter`. All that this interface specifies is the `enable` method that is already implemented by all existing reporters.

Implementors of `ConfiguredReporter` are responsible for the correct configuration of the reporter, and to start it when `enable()` is called.

With this approach, the specific reporter properties and methods in `ReporterConfig` (`csv`, `console`, etc) are not necessary anymore. I have left them, to ensure backward compatibility. This means that all existing yaml files will keep working. Maybe it's good to deprecate the fields/methods, and remove them in a future version.

I have implemented a reporter for [KairosDB](https://github.com/tomvandenberge/metrics-kairosdb), and it works fine. Please let me know what you think of these changes, and if you'd like to pull them in.

Regards,
Tom