Skip to content

Commit

Permalink
Add retry count metric
Browse files Browse the repository at this point in the history
  • Loading branch information
mosmeh committed Dec 16, 2022
1 parent c9d786b commit bc8a8ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.linecorp.decaton.processor.metrics.internal.AvailableTags;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Meter.Id;
Expand Down Expand Up @@ -261,6 +262,12 @@ public class RetryMetrics extends AbstractMetrics {
.description("The number of tasks failed to enqueue in retry topic")
.tags(availableTags.subscriptionScope())
.register(registry));

public final DistributionSummary retryCount =
meter(() -> DistributionSummary.builder("retry.count")
.description("The number of times a task was retried")
.tags(availableTags.subscriptionScope())
.register(registry));
}

public static Metrics withTags(String... keyValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public DecatonTaskRetryQueueingProcessor(SubscriptionScope scope, DecatonTaskPro
public void process(ProcessingContext<byte[]> context, byte[] serializedTask)
throws InterruptedException {
TaskMetadata originalMeta = context.metadata();
long nextRetryCount = originalMeta.retryCount() + 1;
long nextTryTimeMillis = System.currentTimeMillis() + backoff.toMillis();
TaskMetadataProto taskMetadata =
TaskMetadataProto.newBuilder(originalMeta.toProto())
.setRetryCount(originalMeta.retryCount() + 1)
.setRetryCount(nextRetryCount)
.setScheduledTimeMillis(nextTryTimeMillis)
.build();
DecatonTaskRequest request =
Expand All @@ -71,6 +72,7 @@ public void process(ProcessingContext<byte[]> context, byte[] serializedTask)
} else {
metrics.retryQueueingFailed.increment();
}
metrics.retryCount.record(nextRetryCount);
});
context.deferCompletion().completeWith(future);
}
Expand Down

0 comments on commit bc8a8ce

Please sign in to comment.