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

collect connection pool metrics from aws #918

Merged
merged 6 commits into from Nov 2, 2021

Conversation

dbyron-sf
Copy link
Contributor

No description provided.

@@ -62,6 +62,9 @@

private static final Field[] COUNTERS = {
Field.BytesProcessed,
Field.HttpClientPoolAvailableCount,
Field.HttpClientPoolLeasedCount,
Field.HttpClientPoolPendingCount,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these would need to be recorded as gauges rather than counters. Per the docs they represent the current values for a given pool.

Spectator counters are used to measure a rate of change, e.g. bytes processed per second or requests per second. Gauges are used to snapshot a value at a given time, that seems more appropriate for something that is the number of connections currently in a given state for the 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.

Totally agree. 83d916b attempts to address that.

Copy link
Contributor

Choose a reason for hiding this comment

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

The gauge aspect looks fine with this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@brharrington brharrington left a comment

Choose a reason for hiding this comment

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

My big concern here is it isn't clear how well a user can reason about the reported values. In particular, I think each client instance would have a separate connection pool. So if an app has N instances of say AmazonS3Client, then it would be somewhat arbitrary which state was reported.

@brharrington brharrington added this to the 1.0.4 milestone Oct 28, 2021
@dbyron-sf
Copy link
Contributor Author

My big concern here is it isn't clear how well a user can reason about the reported values. In particular, I think each client instance would have a separate connection pool. So if an app has N instances of say AmazonS3Client, then it would be somewhat arbitrary which state was reported.

Totally agree here too, and thanks for pointing this out. I'm planning to stare at this and see if I can come up with some useful tagging strategy to make this work . Wanted to take the baby step of using gauges first, and once that's OK, move on to this.

@dbyron-sf
Copy link
Contributor Author

What do you think of choosing a key and looking for info in the handler context of the request? https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/AmazonWebServiceRequest.html#addHandlerContext-com.amazonaws.handlers.HandlerContextKey-X-

@dbyron-sf
Copy link
Contributor Author

How does e694c6b look?

*/
public SpectatorRequestMetricCollector(Registry registry, Map<String, String> customTags) {
this(registry, customTags, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brharrington Actually as I stare at this it would be really helpful for all the bean wiring, etc. to have a default context key. What do you think of e.g. https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/handlers/HandlerContextKey.html#OPERATION_NAME?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here goes: c089bbb

Copy link
Contributor

Choose a reason for hiding this comment

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

Operation name seems reasonable.

@@ -156,6 +203,10 @@ private Id metricId(String metric, Map<String, String> tags) {
allTags.put(tag.getName(), tag.getValue(metrics).orElse(UNKNOWN));
}
allTags.put(TAG_REQUEST_TYPE, request.getOriginalRequest().getClass().getSimpleName());
String contextTagValue = request.getHandlerContext(handlerContextKey);
if (contextTagValue != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the gauges be contingent on the context being set? Otherwise existing users might start getting the gauges for pool metrics and not realize that the values reported do not make sense when they have multiple pools in use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense: 5b77464

@brharrington brharrington merged commit b6e6e4a into Netflix:master Nov 2, 2021
@dbyron-sf dbyron-sf deleted the add-connection-pool-counters branch November 2, 2021 18:23
@dbyron-sf
Copy link
Contributor Author

Thanks much!

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.

None yet

2 participants