At the moment we have a library that exports JMX metrics (using Dropwizard). Now there is a requirement to optionally, in addition support InfluxDB (but not via Dropwizard's Reporter
s). That is, JMX metrics are always to be reported, and InfluxDB ones should be reported only if a flag was given during the start.
Now, I'm looking for a pattern which would enable me to support this. We have several classes, like Counter
, Timer
, Gauge
. Objects are produced by factory methods in Metrics
class. Initially, I started by extracting traits of existing classes, and then having an implementation 3 implementations: one for original JMX metrics, one for InfluxDB, and one which combines both. Then, based on a flag read when Metrics
object is created, each method would pick up the correct implementation. However, this smells. Is there a better pattern to use?
Aucun commentaire:
Enregistrer un commentaire