Skip to content

[client-v2] Measure connection establishment time - #3353

Open
utkarshb1209 wants to merge 1 commit into
ClickHouse:mainfrom
utkarshb1209:issue-3254-httpclient-connect-time
Open

utkarshb1209 wants to merge 1 commit into
ClickHouse:mainfrom
utkarshb1209:issue-3254-httpclient-connect-time

Conversation

@utkarshb1209

@utkarshb1209 utkarshb1209 commented Nov 15, 2026 •

Copy link
Copy Markdown

Fixes httpcomponents.httpclient.connect.time in client-v2.

Previously, the metric measured connection object creation time rather than actual connection establishment time.

This change moves timing to the HTTP client connection operator and measures the duration of the connection operation, including DNS resolution, TCP connection, and TLS handshake for new direct connections.

Additional changes:

Uses System.nanoTime() to retain sub-millisecond precision.

Reports the average connection establishment time in milliseconds.

Does not record additional samples when an existing pooled connection is reused.

Updates the connection metrics documentation and changelog.

Closes #3254


Note

Low Risk
Observability-only change to how connect timing is sampled and exposed; no query, auth, or transport behavior changes beyond metric accuracy.

Overview
Fixes httpcomponents.httpclient.connect.time so it measures real connection establishment (via a new MeteredHttpClientConnectionOperator around Apache HttpClient’s connect path), not time spent wrapping an already-connected socket in MeteredManagedHttpClientConnectionFactory.

The pooled connection manager builder now installs that operator; samples use System.nanoTime(), are averaged in milliseconds for Micrometer, and are not recorded when metrics are off or when a pooled connection is reused. Tests cover delayed TCP/TLS, end-to-end client metrics (HTTP/HTTPS), and the integration testConnectionTime case is re-enabled.

Reviewed by Cursor Bugbot for commit a052634. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client-v2] httpcomponents.httpclient.connect.time does not include the TCP connect or the TLS handshake

1 participant