Skip to content

client: add aggregate connection count metrics#2201

Merged
erikdubbelboer merged 2 commits into
valyala:masterfrom
z9z:client-aggregate-conn-metrics
May 17, 2026
Merged

client: add aggregate connection count metrics#2201
erikdubbelboer merged 2 commits into
valyala:masterfrom
z9z:client-aggregate-conn-metrics

Conversation

@z9z
Copy link
Copy Markdown
Contributor

@z9z z9z commented May 6, 2026

Adds Client.ConnsCount() and Client.IdleConnsCount(), aggregating across all managed HostClients (both http and https maps). Also adds HostClient.IdleConnsCount() since there was no public accessor for per-host idle count.

Closes #2200

Comment thread client_test.go Outdated
Comment on lines +123 to +134
func TestClientConnectionCountsEmpty(t *testing.T) {
t.Parallel()

var c Client
if n := c.ConnsCount(); n != 0 {
t.Fatalf("unexpected connection count %d. Expecting %d", n, 0)
}
if n := c.IdleConnsCount(); n != 0 {
t.Fatalf("unexpected idle connection count %d. Expecting %d", n, 0)
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already tested in the above test as well, please remove this test.

@erikdubbelboer erikdubbelboer merged commit 6d7682a into valyala:master May 17, 2026
11 checks passed
@erikdubbelboer
Copy link
Copy Markdown
Collaborator

Thanks!

@z9z z9z deleted the client-aggregate-conn-metrics branch May 17, 2026 11:32
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: add aggregate connection pool metrics for observability

2 participants