You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clean up Micrometer callbacks when meters are removed or registries close - #21569
Closing an application-owned Micrometer registry can leave its observable callbacks registered with OpenTelemetry. Unregister callbacks when the registry closes or a meter is removed, including callbacks for time gauges and meters hidden from search.
Anything look wrong?Report it with what you expected; it helps us improve the dashboard.
trask
changed the title
[WIP] Extract explicit cleanup layer from open-telemetry/opentelemetry-java-instrumentation#21372
Clean up Micrometer callbacks without disrupting Spring’s global registry
Nov 28, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The time-gauge wrapper lacks the OpenTelemetryInstrument marker, allowing composite reads to select a forwarding-only child and return NaN instead of reading from a capable registry.
Updates the Micrometer bridge to release observable callbacks when meters are removed or caller-owned registries close, while preserving the javaagent’s shared registry across Spring context shutdown.
Changes:
Adds idempotent callback cleanup, including hidden meters and time gauges.
Retains generic measurements until removal and protects the shared registry from both Spring closer implementations.
Adds lifecycle and shutdown regression tests and updates the API diff.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The nested registry closer constructor-advice path lacks integration coverage verifying that shutdown keeps the agent globally registered while closing and detaching Spring-owned registries.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add integration coverage for Boot 3.5 constructor-advice shutdown
This constructor-advice path has no integration coverage: the module's default test dependency is Boot 2.0 (which has no registry closer), while the newer Boot 4 implementation uses the standalone closer. The new shutdown test therefore does not verify removal from the nested closer's Iterable, the separate path used by the current Boot 3.5 implementation. Please add a wired agent-test execution pinned to a supported release with this constructor shape and run the shutdown regression there, checking that the agent remains globally registered while Spring-owned registries are closed and detached.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The lazily registered test suite can be skipped by normal check, leaving the Spring Boot 3.5.16 shutdown regression untested without an explicit lifecycle dependency.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Missing lifecycle coverage for custom-meter ownership and cleanup requires human judgment about potential premature collection or retention regressions.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The measurement-retention change lacks garbage-collection regression tests for observation survival and release of supplier-captured state after removal and registry close.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing an application-owned Micrometer registry can leave its observable callbacks registered with OpenTelemetry. Unregister callbacks when the registry closes or a meter is removed, including callbacks for time gauges and meters hidden from search.