We use Micrometer in our Spring Boot applications.
When shutting down our applications we sometimes get WARN log messages with Exceptions that say:
Failed to apply the value function for the gauge (...)
All of these value functions fail because some part of the application is already shut down. For example, we have a metric that's based on a Spring Data Repository, so we get
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'entityManagerFactory': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
I assume this would be avoidable if publishing of Metrics is stopped by calling MeterRegistry.clear() and PushMeterRegistry.stop() when the shutdown begins.
(We are using Datadog, which apparently implements PushMeterRegistry)