Skip to content

Metrics: Add interfaces and initial implementations #1362

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

Merged
merged 3 commits into from
Jan 9, 2020

Conversation

spfink
Copy link
Contributor

@spfink spfink commented Jul 25, 2019

Continuing the work from: #1314

/**
* Service ID of the AWS service that the API request is made against
*/
Service("Service", DEFAULT),
Copy link
Contributor

Choose a reason for hiding this comment

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

This enum needs to be updated to use upper case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update.

public Builder metricConfigurationProvider(MetricConfigurationProvider metricConfigurationProvider) {
this.metricConfigurationProvider = metricConfigurationProvider;
return this;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

missing setters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add

/**
* A NoOp implementation of {@link MetricRegistry} interface.
*/
@SdkProtectedApi
Copy link
Contributor

Choose a reason for hiding this comment

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

internal api?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

* Utilities used for handling shared metric tasks during the request lifecycle.
*/
@SdkInternalApi
public final class MetricUtil {
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this util class different from MetricUtils? Can we put them into one class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't realize MetricUtils existed when I wrote MetricUtil and forgot to go back and combine once I did realize


@Override
public Set<MetricCategory> metricCategories() {
return categories;
Copy link
Contributor

Choose a reason for hiding this comment

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

should return immutable set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, can switch the resolveCategories to use an immutable set. In the future, it's possible to change these at runtime so this would introduce a bunch of copying as this method is called frequently...

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

public static final ExecutionAttribute<MetricPublisherConfiguration> METRIC_PUBLISHER_CONFIGURATION =
new ExecutionAttribute<>("MetricPublisherConfiguration");

protected MetricExecutionAttribute() {
Copy link
Contributor

Choose a reason for hiding this comment

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

private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep

@@ -102,9 +114,16 @@ private RetryExecutor(SdkHttpFullRequest request, RequestExecutionContext contex
}

public CompletableFuture<Response<OutputT>> execute(CompletableFuture<Response<OutputT>> future) throws Exception {
MetricRegistry attemptRegistry = MetricUtil.newRegistry(context.executionAttributes());
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move line 117 - line 120 to beforeExecute method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would need to store a reference to the timer then.

@@ -119,7 +122,11 @@ public MakeAsyncHttpRequestStage(TransformingAsyncResponseHandler<OutputT> respo
.fullDuplex(isFullDuplex(context.executionAttributes()))
.build();

Timer timer = MetricUtils.timer(context.attemptMetricRegistry(), SdkDefaultMetric.HttpRequestRoundTripLatency);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract the timer code to a separate method, say startTimer()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the benefit here? I can change MetricUtils.timer method to start and return the timer but not really sure how much that is saving...

Copy link
Contributor

Choose a reason for hiding this comment

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

To me, the benefit is to isolate metrics logic and to keep executeHttpRequest method smaller, simpler and just doing one thing (though it's already doing multiple things right now)


MetricRegistry attemptRegistry = MetricUtil.newRegistry(context.executionAttributes());
Timer apiCallAttemptTimer = MetricUtils.timer(attemptRegistry, SdkDefaultMetric.ApiCallAttemptLatency);
apiCallAttemptTimer.start();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract the timer code to a separate method, say startTimer()?


client = CodePipelineClient.builder()
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
// .overrideConfiguration(configuration)
Copy link
Contributor

Choose a reason for hiding this comment

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

can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to look this class over again. Probably not worthwhile to include until publisher is added

@spfink spfink force-pushed the finks-varunkn/metrics branch from 739682f to ed5e529 Compare July 25, 2019 23:35
@millems millems mentioned this pull request Sep 13, 2019
@dagnir dagnir changed the base branch from master to sdk-metrics-development January 9, 2020 21:19
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@dagnir dagnir merged commit 07ef8a6 into sdk-metrics-development Jan 9, 2020
@dagnir dagnir deleted the finks-varunkn/metrics branch January 9, 2020 22:23
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.

3 participants