-
Notifications
You must be signed in to change notification settings - Fork 910
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
Conversation
/** | ||
* Service ID of the AWS service that the API request is made against | ||
*/ | ||
Service("Service", DEFAULT), |
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.
This enum needs to be updated to use upper case
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.
Will update.
public Builder metricConfigurationProvider(MetricConfigurationProvider metricConfigurationProvider) { | ||
this.metricConfigurationProvider = metricConfigurationProvider; | ||
return this; | ||
} |
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.
missing setters
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.
Will add
/** | ||
* A NoOp implementation of {@link MetricRegistry} interface. | ||
*/ | ||
@SdkProtectedApi |
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.
internal api?
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.
Sure
* Utilities used for handling shared metric tasks during the request lifecycle. | ||
*/ | ||
@SdkInternalApi | ||
public final class MetricUtil { |
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.
How is this util class different from MetricUtils
? Can we put them into one class?
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.
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; |
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.
should return immutable set
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.
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...
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.
👍
public static final ExecutionAttribute<MetricPublisherConfiguration> METRIC_PUBLISHER_CONFIGURATION = | ||
new ExecutionAttribute<>("MetricPublisherConfiguration"); | ||
|
||
protected MetricExecutionAttribute() { |
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.
private?
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.
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()); |
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.
Would it make sense to move line 117 - line 120 to beforeExecute
method
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.
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); |
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.
Can we extract the timer code to a separate method, say startTimer()
?
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.
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...
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.
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(); |
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.
Can we extract the timer code to a separate method, say startTimer()?
|
||
client = CodePipelineClient.builder() | ||
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) | ||
// .overrideConfiguration(configuration) |
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.
can be removed?
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.
Need to look this class over again. Probably not worthwhile to include until publisher is added
739682f
to
ed5e529
Compare
Kudos, SonarCloud Quality Gate passed!
|
Continuing the work from: #1314