metrics
metrics copied to clipboard
ScheduledReporter reports metrics when stopped/closed even when not started
trafficstars
ScheduledReporter's close method calls its stop method, which calls report to report the metrics "one last time". This also happens if start has never been called.
In a SpringBoot application that registers a ScheduledReporter as a bean, this can lead to strange behavior since the stop method is automatically called by Spring Boot.
My assumption is the logic was indeed "one last time" or metrics would be lost. What's wrong with this? I suspect you could subclass and override close. And track with AtomicBoolean.compareAndSet
I've opened #4246 for this issue. I've just added a check whether the reporter has been started.