Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added metrics for OkHttp connection pool #2066

Conversation

benhubert
Copy link
Contributor

@benhubert benhubert commented May 7, 2020

See #1875

@jkschneider
Copy link
Contributor

jkschneider commented May 8, 2020

What I don't like about it, that the idle value is a subset of total, so accessing okhttp.pool.connection.count without any tag won't give you the overall sum. Instead it will give you the overall sum + the idle connections, which is not a useful value.

I think I've got a solution for the synchronization problem. Give me a few moments.

@jkschneider jkschneider added this to the 1.6.0 milestone May 8, 2020
@jkschneider jkschneider added the enhancement A general enhancement label May 8, 2020
@jkschneider jkschneider changed the title added metrics for OkHttp connection pool #1875 added metrics for OkHttp connection pool May 8, 2020
@jkschneider
Copy link
Contributor

Fixes #1875

@jkschneider
Copy link
Contributor

jkschneider commented May 8, 2020

See if this makes sense @benhubert. We just hold total and idle together in a wrapper and use a CountDownLatch to refresh the stats whenever both gauges have been published and one tries to access the value on the next publish interval.

The stats wrapper is held in a ThreadLocal so if multiple metrics publishings happen simultaneously (e.g. multiple overlapping Prometheus scrapes), then the synchronization is only for the two gauges being published as part of the same metrics publishing operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants