remove metrics from MeterRegistry when shutting down InstrumentedQueuedThreadPool
Something like:
@Override
protected void doStop() throws Exception {
Set<Tag> tagSet = new HashSet<>();
tags.forEach(tagSet::add);
Stream.of("jetty.threads.config.min",
"jetty.threads.config.max",
"jetty.threads.busy",
"jetty.threads.jobs",
"jetty.threads.current",
"jetty.threads.idle")
.flatMap(name -> meterRegistry.find(name).meters().stream())
.map(Meter::getId)
.filter(id -> new HashSet<>(id.getTags()).containsAll(tagSet))
.forEach(meterRegistry::remove);
super.doStop();
}
Rationale
Clean up resources when not needed anymore
Additional context
The dropwizard metrics jetty InstrumentedQueuedThreadPool does something similar, and it seems like a good idea to do here as well.
I am happy to open a PR for this with tests if it is agreed that this should exist.
Thanks
remove metrics from MeterRegistry when shutting down InstrumentedQueuedThreadPool
Something like:
Rationale
Clean up resources when not needed anymore
Additional context
The dropwizard metrics jetty InstrumentedQueuedThreadPool does something similar, and it seems like a good idea to do here as well.
I am happy to open a PR for this with tests if it is agreed that this should exist.
Thanks