-
Notifications
You must be signed in to change notification settings - Fork 16
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 connection pool instrumentation #457
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
da57615
Apache connection pool instrumentation
iamdanfox 344fb30
real types instead of tritium
iamdanfox b20e460
Add generated changelog entries
iamdanfox 930be65
Needless indirection
iamdanfox 37886cd
test after response closed
iamdanfox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: improvement | ||
improvement: | ||
description: Each closeable apache client now exposes methods which reveal statistics | ||
about the connection pool. | ||
links: | ||
- https://github.com/palantir/dialogue/pull/457 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*/ | ||
package com.palantir.dialogue.hc4; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import com.google.common.util.concurrent.Futures; | ||
|
@@ -58,6 +59,26 @@ public void close_works() throws Exception { | |
assertThatThrownBy(() -> again.get()).hasMessageContaining("Connection pool shut down"); | ||
} | ||
|
||
@Test | ||
public void metrics() throws Exception { | ||
ClientConfiguration conf = TestConfigurations.create("http://unused"); | ||
|
||
try (ApacheHttpClientChannels.CloseableClient client = | ||
ApacheHttpClientChannels.createCloseableHttpClient(conf)) { | ||
|
||
Channel channel = ApacheHttpClientChannels.createSingleUri("http://neverssl.com", client); | ||
ListenableFuture<Response> response = | ||
channel.execute(new TestEndpoint(), Request.builder().build()); | ||
assertThat(Futures.getUnchecked(response).code()).isEqualTo(200); | ||
|
||
assertThat(client.getNumRoutes()).describedAs("routes").isEqualTo(1); | ||
assertThat(client.getPoolStats().getAvailable()) | ||
.describedAs("available") | ||
.isEqualTo(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think graphing the number /**
* Gets the number idle persistent connections.
* <p>
* The total number of connections in the pool is equal to {@code available} plus {@code leased}.
* </p>
*
* @return number idle persistent connections.
*/
public int getAvailable() { |
||
assertThat(client.getPoolStats().getLeased()).describedAs("leased").isEqualTo(1); | ||
} | ||
} | ||
|
||
private static final class TestEndpoint implements Endpoint { | ||
@Override | ||
public void renderPath(Map<String, String> _params, UrlBuilder _url) {} | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can wrap these to add a meter of connection rate, and wrap the pool manager to capture the rate connections requested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm that would be cool, so dividing one by the other tells us how effectively we're re-using... Do we not already get that connection rate from the tritium tls.handshakes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tritium handshake instrumentation would work assuming https, but I don’t think we wire it up yet.