Skip to content

Commit

Permalink
rename a metric
Browse files Browse the repository at this point in the history
  • Loading branch information
idegtiarenko committed Oct 10, 2023
1 parent aeda7e8 commit f409e60
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public class S3RequestRetryStats {
private static final Logger logger = LogManager.getLogger(S3RequestRetryStats.class);

private final AtomicLong requests = new AtomicLong();
private final AtomicLong retries = new AtomicLong();
private final AtomicLong exceptions = new AtomicLong();
private final AtomicLong throttles = new AtomicLong();
private final AtomicLongArray retriesHistogram;
private final AtomicLongArray exceptionsHistogram;
private final AtomicLongArray throttlesHistogram;

public S3RequestRetryStats(int maxRetries) {
this.retriesHistogram = new AtomicLongArray(maxRetries);
this.throttlesHistogram = new AtomicLongArray(maxRetries);
this.exceptionsHistogram = new AtomicLongArray(maxRetries + 1);
this.throttlesHistogram = new AtomicLongArray(maxRetries + 1);
}

public void addRequest(Request<?> request) {
Expand All @@ -44,14 +44,14 @@ public void addRequest(Request<?> request) {
}
var info = request.getAWSRequestMetrics().getTimingInfo();
long requests = getCounter(info, AWSRequestMetrics.Field.RequestCount);
long retries = getCounter(info, AWSRequestMetrics.Field.Exception);
long exceptions = getCounter(info, AWSRequestMetrics.Field.Exception);
long throttles = getCounter(info, AWSRequestMetrics.Field.ThrottleException);

this.requests.addAndGet(requests);
this.retries.addAndGet(retries);
this.exceptions.addAndGet(exceptions);
this.throttles.addAndGet(throttles);
if (retries >= 0 && retries < this.retriesHistogram.length()) {
this.retriesHistogram.incrementAndGet((int) retries);
if (exceptions >= 0 && exceptions < this.exceptionsHistogram.length()) {
this.exceptionsHistogram.incrementAndGet((int) exceptions);
}
if (throttles >= 0 && throttles < this.throttlesHistogram.length()) {
this.throttlesHistogram.incrementAndGet((int) throttles);
Expand All @@ -66,10 +66,10 @@ private static long getCounter(TimingInfo info, AWSRequestMetrics.Field field) {
public void emitMetrics() {
if (logger.isDebugEnabled()) {
emitMetric("elasticsearch.s3.requests", requests.get());
emitMetric("elasticsearch.s3.retries", retries.get());
emitMetric("elasticsearch.s3.exceptions", exceptions.get());
emitMetric("elasticsearch.s3.throttles", throttles.get());
for (int i = 0; i < retriesHistogram.length(); i++) {
emitMetric("elasticsearch.s3.retries." + i, retriesHistogram.get(i));
for (int i = 0; i < exceptionsHistogram.length(); i++) {
emitMetric("elasticsearch.s3.exceptions." + i, exceptionsHistogram.get(i));
}
for (int i = 0; i < throttlesHistogram.length(); i++) {
emitMetric("elasticsearch.s3.throttles." + i, throttlesHistogram.get(i));
Expand Down

0 comments on commit f409e60

Please sign in to comment.