Repository navigation
Conversation
Pull request dashboard statusWaiting on reviewers · refreshed 2026-12-04 05:02 UTC Review the latest changes. Status above doesn't look right?
|
There was a problem hiding this comment.
🟡 Changes recommended
Supplier and strong-reference gauges can fall back to Meter.Id callback ownership, retaining plugin class loaders when Micrometer is shared with the agent.
2 open issues
What changed in this PR
Introduces agent-specific callback ownership for Micrometer class-loader cleanup, building on #21569 while preserving standalone-library registration behavior.
Changes:
- Routes observable-meter callbacks through an internal registration abstraction.
- Uses weak SDK delegates with class-scoped ownership and explicit release on removal.
- Adds Gauge and TimeGauge regressions for disposable and shared class loaders.
| File | Description |
|---|---|
| OpenTelemetryMeterRegistryBuilder.java | Defaults to direct registration and accepts an internal override. |
| OpenTelemetryMeterRegistry.java | Passes the registrar and ownership metadata to observable meters. |
| OpenTelemetryMeter.java | Routes custom-meter callbacks through the registrar. |
| OpenTelemetryLongTaskTimer.java | Manages active-task and duration callback registrations. |
| OpenTelemetryGauge.java | Registers gauge callbacks with function ownership metadata. |
| OpenTelemetryFunctionTimer.java | Applies ownership handling to count and total-time callbacks. |
| OpenTelemetryFunctionCounter.java | Applies ownership handling to function-counter callbacks. |
| ObservableCallbackRegistrar.java | Defines registration handles, release hooks, and the direct default. |
| Internal.java | Adds the internal registrar configuration bridge. |
| MicrometerCallbackGcCloseTest.java | Tests metric export and class-loader collection. |
| GaugeRegistrar.java | Supplies disposable-loader Gauge and TimeGauge fixtures. |
| MicrometerSingletons.java | Enables the agent-specific registrar. |
| MicrometerCallbackRegistrar.java | Implements weak delegation, ownership selection, and release. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The parent-only callback ownership lookup fails under sibling-loader delegation, causing the shared Meter.Id ClassValue entry to retain the application's measurement function and class loader and prevent unloading.
1 open issue
2 resolved since last review
Review effort: Balanced
b7a0071 to
a16a100
Compare
There was a problem hiding this comment.
Note
This is an experimental automated review from the OpenTelemetry PR review workflow. It can miss problems or flag things that are fine, so treat its findings as suggestions.
23f941a to
397f954
Compare
|
Note This is an experimental automated review from the OpenTelemetry PR review workflow. It can miss problems or flag things that are fine, so treat its findings as suggestions. No findings on commit |
Fix wrapped Micrometer gauge callback ownership Run wrapped TimeGauge test when supported Simplify Micrometer callback registration and tests Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep direct SDK callback registration in every registry. Defer Java agent ownership and wrapped gauge handling to follow-up changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
3f651af to
cdbb699
Compare



When a web app bundles Micrometer and registers a gauge through
Metrics.globalRegistry, the Java agent's SDK can keep the app's class loader alive after undeploy. This PR breaks that strong reference path without interrupting gauge collection while the app runs.The Micrometer instrumentation class loader keeps callbacks alive and can unload with the app. Removing a meter releases its callback. Standalone registries still register directly.
Apps that share Micrometer still report, but a shared
Metrics.globalRegistrycan retain an undeployed app through its own measurement functions.