Skip to content

Commit

Permalink
Derive aws sdk retry count from request count
Browse files Browse the repository at this point in the history
  • Loading branch information
ljw9111 authored and pettyjamesm committed Jan 2, 2025
1 parent 1a4bdbf commit c06f1e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class AwsSdkClientCoreStats
{
private final CounterStat awsRequestCount = new CounterStat();
private final CounterStat awsRetryCount = new CounterStat();
private final CounterStat awsHttpClientRetryCount = new CounterStat();
private final CounterStat awsThrottleExceptions = new CounterStat();
private final TimeStat awsRequestTime = new TimeStat(MILLISECONDS);
private final TimeStat awsClientExecuteTime = new TimeStat(MILLISECONDS);
Expand All @@ -66,6 +67,13 @@ public CounterStat getAwsRetryCount()
return awsRetryCount;
}

@Managed
@Nested
public CounterStat getAwsHttpClientRetryCount()
{
return awsHttpClientRetryCount;
}

@Managed
@Nested
public CounterStat getAwsThrottleExceptions()
Expand Down Expand Up @@ -134,12 +142,16 @@ public void collectMetrics(Request<?> request, Response<?> response)

Number requestCounts = timingInfo.getCounter(RequestCount.name());
if (requestCounts != null) {
stats.awsRequestCount.update(requestCounts.longValue());
long count = requestCounts.longValue();
stats.awsRequestCount.update(count);
if (count > 1) {
stats.awsRetryCount.update(count - 1);
}
}

Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
if (retryCounts != null) {
stats.awsRetryCount.update(retryCounts.longValue());
Number httpClientRetryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
if (httpClientRetryCounts != null) {
stats.awsHttpClientRetryCount.update(httpClientRetryCounts.longValue());
}

Number throttleExceptions = timingInfo.getCounter(ThrottleException.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class AwsSdkClientCoreStats
{
private final CounterStat awsRequestCount = new CounterStat();
private final CounterStat awsRetryCount = new CounterStat();
private final CounterStat awsHttpClientRetryCount = new CounterStat();
private final CounterStat awsThrottleExceptions = new CounterStat();
private final TimeStat awsRequestTime = new TimeStat(MILLISECONDS);
private final TimeStat awsClientExecuteTime = new TimeStat(MILLISECONDS);
Expand All @@ -66,6 +67,13 @@ public CounterStat getAwsRetryCount()
return awsRetryCount;
}

@Managed
@Nested
public CounterStat getAwsHttpClientRetryCount()
{
return awsHttpClientRetryCount;
}

@Managed
@Nested
public CounterStat getAwsThrottleExceptions()
Expand Down Expand Up @@ -134,12 +142,16 @@ public void collectMetrics(Request<?> request, Response<?> response)

Number requestCounts = timingInfo.getCounter(RequestCount.name());
if (requestCounts != null) {
stats.awsRequestCount.update(requestCounts.longValue());
long count = requestCounts.longValue();
stats.awsRequestCount.update(count);
if (count > 1) {
stats.awsRetryCount.update(count - 1);
}
}

Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
if (retryCounts != null) {
stats.awsRetryCount.update(retryCounts.longValue());
Number httpClientRetryCounts = timingInfo.getCounter(HttpClientRetryCount.name());
if (httpClientRetryCounts != null) {
stats.awsHttpClientRetryCount.update(httpClientRetryCounts.longValue());
}

Number throttleExceptions = timingInfo.getCounter(ThrottleException.name());
Expand Down

0 comments on commit c06f1e1

Please sign in to comment.