Skip to content

Prevent Micrometer global registry from pinning application contexts#50886

Open
LordKay-sudo wants to merge 1 commit into
spring-projects:mainfrom
LordKay-sudo:gh-36737-meter-registry-global-cleanup
Open

Prevent Micrometer global registry from pinning application contexts#50886
LordKay-sudo wants to merge 1 commit into
spring-projects:mainfrom
LordKay-sudo:gh-36737-meter-registry-global-cleanup

Conversation

@LordKay-sudo

Copy link
Copy Markdown

Summary

Related to spring-framework#36737.

  • Fix MeterRegistryCloser so it tracks registries added to Metrics.globalRegistry at registration time instead of snapshotting MeterRegistry beans in its constructor (which often runs before registries exist).
  • On ContextClosedEvent, remove tracked registries from the global registry and close them.
  • Add DisableGlobalMeterRegistryContextCustomizerFactory so tests default management.metrics.use-global-registry=false when not explicitly configured, mirroring the existing Reactor global-resources customizer and preventing cached test contexts from being pinned via Micrometer.

Test plan

  • ./gradlew :module:spring-boot-micrometer-metrics:test --tests MeterRegistryPostProcessorTests
  • ./gradlew :core:spring-boot-test:test --tests DisableGlobalMeterRegistryContextCustomizerFactoryTests

Track meter registries added to Metrics.globalRegistry and remove them on context close. Disable use of the global registry in tests by default to avoid pinning cached test contexts.

Signed-off-by: LordKay-sudo <lkandiro@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants