Configure MeterBinders after beans have been created

Update `MeterRegistryPostProcessor` to configure `MeterRegistry` beans
in two distinct sweeps. The first sweep applies customizers and filters
as the `MeterRegistry` bean is initialized, the second sweep applies
`MeterBinder` beans once all singletons have been instantiated.

Prior to this commit, it was not possible for a `MeterBinder` bean to
directly or indirectly use a `MeterRegistry`. It was also possible for
bound meters to cause a deadlock during refresh processing if those
meters could be updated on a thread other than main, such as GC
notifications.

Fixes gh-30636
Fixes gh-33070
This commit is contained in:
Phillip Webb
2022-05-18 15:21:04 -07:00
committed by Andy Wilkinson
parent e60084112e
commit e5a0b164ac
7 changed files with 244 additions and 166 deletions

View File

@@ -11,7 +11,7 @@
<suppress files="LogbackLoggingSystem\.java" checks="IllegalImport" />
<suppress files="LogbackLoggingSystemTests\.java" checks="IllegalImport" />
<suppress files="LogbackConfigurationAotContributionTests\.java" checks="IllegalImport" />
<suppress files="MeterRegistryConfigurerIntegrationTests\.java" checks="IllegalImport" />
<suppress files="MetricsAutoConfigurationMeterRegistryPostProcessorIntegrationTests\.java" checks="IllegalImport" message="LoggerFactory"/>
<suppress files="SpringApplicationTests\.java" checks="FinalClass" />
<suppress files=".+Configuration\.java" checks="HideUtilityClassConstructor" />
<suppress files=".+Application\.java" checks="HideUtilityClassConstructor" />