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

Apache client connection pool instrumentation #498

Merged
merged 11 commits into from
Mar 6, 2020

Conversation

carterkozak
Copy link
Contributor

See #457

After this PR

==COMMIT_MSG==
Apache client connection pool instrumentation
==COMMIT_MSG==

Function<PoolingHttpClientConnectionManager, T> extractor, BiFunction<T, T, T> combiner, T initial) {
T current = initial;
Iterator<WeakReference<PoolingHttpClientConnectionManager>> iterator = pools.iterator();
while (iterator.hasNext()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

for loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For loop doesn't allow the iterator.remove operation we use when a garbage collected item is encountered.

// Increased from two seconds to twenty-five seconds because we have strong support for retries
// and can optimistically avoid expensive connection checks.
connectionManager.setValidateAfterInactivity(
Ints.checkedCast(Duration.ofSeconds(25).toMillis()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I snuck in a behavior change here, I can pull this into a separate PR if you prefer. I dropped it here because this PR adds direct access to the PoolingHttpClientConnectionManager, which is the only to configure setValidateAfterInactivity

.evictIdleConnections(55, TimeUnit.SECONDS)
.setMaxConnPerRoute(Integer.MAX_VALUE)
.setMaxConnTotal(Integer.MAX_VALUE)
// TODO(ckozak): proxy credentials
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this stale TODO, it's TODONE

javaPackage: com.palantir.dialogue.hc4
javaVisibility: packagePrivate
namespaces:
dialogue.client.pool:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The metric name doesn't reference the apache client, I tried to keep it as general as possible so we could implement it for other clients in the future if applicable. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of having consistent metric regardless of underlying client implementation. We can update the docs if we decide to work on another client

@ferozco
Copy link
Contributor

ferozco commented Mar 6, 2020

👍

@bulldozer-bot bulldozer-bot bot merged commit 40315cc into develop Mar 6, 2020
@bulldozer-bot bulldozer-bot bot deleted the ckozak/connection_pool_instrumentation branch March 6, 2020 16:18
@svc-autorelease
Copy link
Collaborator

Released 0.16.2

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

Successfully merging this pull request may close these issues.

4 participants