Use JmxReporter.Builder.filter to handle exclusion rules
Since the support for excluding some metrics from being reported was
added in Ib4da8ba8ad5d6ba3f1cbb0b3f83375cfcef3af67, this metric reporter
was broken: it computed the set of metrics to be exposed once and then
exposed this fixed (sub)set forever. Any newly added metrics were not
exposed. For example: if a plugin which exposes metrics loads after this
plugin, these metrics would be exposed via JMX. Further, even some
metrics bound via a MetricModule in Gerrit core wouldn't be reported by
this plugin if that MetricModule (which is also a LifeCycleModule)
happens to receive its start() call after this plugin already computed
the snapshot of exposed metrics.
Instead of copying the set of exposed metrics in a new MetricRegistry,
apply a MetricFilter to the MetricRegistry instance from Gerrit core.
Handle exclusion rules through that filter.
Change-Id: Iaf0b4fa03293ccc2313ab0332f70a3a41ea30a25
1 file changed