Skip to content

Commit 8886618

Browse files
committed
Don't log RateLimitExceeded exceptions
1 parent b189520 commit 8886618

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/signal/cdsi/limits/cosmos/CosmosTokenRateLimiter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public CompletableFuture<Void> prepare(final String key, final int amountDelta,
230230
// check if the request would be rate limited without actually using the rate limit
231231
checkRateLimit(bucketRef[0], requestSize);
232232
} catch (RateLimitExceededException e) {
233+
meterRegistry.counter(validateCounterName, "outcome", "requestWouldExceedRateLimit").increment();
233234
return Mono.error(e);
234235
}
235236
final TokenCost cost = TokenCost.create(key, newTokenId, requestSize, now.toString(), getTtl());
@@ -238,7 +239,8 @@ public CompletableFuture<Void> prepare(final String key, final int amountDelta,
238239
return this.container.createItem(cost, new PartitionKey(cost.getKey()), new CosmosItemRequestOptions());
239240
})
240241
.onErrorMap(CosmosException.class, CosmosTokenRateLimiter::marshal)
241-
.doOnError(e -> logger.warn("Failed to persist token cost for {}", KeyToken.of(key, newTokenId), e))
242+
.doOnError(e -> !(CompletionExceptions.unwrap(e) instanceof RateLimitExceededException), e ->
243+
logger.warn("Failed to persist token cost for {}", KeyToken.of(key, newTokenId), e))
242244
.doFinally(ignore -> sample.stop(prepareTimer))
243245
.toFuture().thenApply(ignored -> null);
244246
}

0 commit comments

Comments
 (0)