Repository navigation
fix(client-v2): record connection times only when metrics are enabled - #3309
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 32c65d7. Configure here.
chernser
previously approved these changes
Nov 9, 2026
chernser
approved these changes
Nov 10, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
MeteredManagedHttpClientConnectionFactory.createConnectionadds the connection creation time to aConcurrentLinkedQueueon every new pooled connection, but the queue is only drained bygetTime(), which only the Micrometer gauge calls, and that gauge is registered only when a metrics registry is configured. Without a registry (the default, and always injdbc-v2), one queue node is retained per new connection for the life of theClient.The factory now records times only after
enableMetrics()is called, whichHttpAPIClientHelperdoes only when a metrics registry is present, right before the gauge is bound. Behaviour with a registry is unchanged.Closes #3253
Checklist
MeteredConnectionFactoryTest: nothing is queued without metrics; times are recorded and drained once enabled. The first test fails before the fix with expected 0, found 10.)history/latest/3253.md)This PR was prepared with the assistance of an AI coding tool (Claude); the change was reviewed before submission.
Note
Low Risk
Targeted change to optional metrics bookkeeping in the HTTP connection factory; behavior with a configured metrics registry is unchanged.
Overview
Fixes a memory leak in the pooled HTTP client: every new connection used to push a duration into an internal queue that is only drained when the Micrometer
httpcomponents.httpclient.connect.timegauge runs. Clients without a metrics registry (includingjdbc-v2) never drained that queue.MeteredManagedHttpClientConnectionFactorynow records connection times only afterenableMetrics();HttpAPIClientHelperenables that when binding Micrometer metrics and callsdisableMetrics()(clearing the queue) if registration fails. Unit tests cover the no-metrics, enabled, and disabled paths.Reviewed by Cursor Bugbot for commit 120fef9. Bugbot is set up for automated code reviews on this repo. Configure here.