Skip to content

Commit

Permalink
chore: improve model rate limit logs (#354)
Browse files Browse the repository at this point in the history
Co-authored-by: Aliaksandr Stsiapanay <[email protected]>
  • Loading branch information
astsiapanay and astsiapanay authored Jun 6, 2024
1 parent f05fdad commit 39ba0c6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Future<?> handle(String deploymentId, String deploymentApi) {
if (result.status() == HttpStatus.OK) {
handleRateLimitSuccess(deploymentId);
} else {
handleRateLimitHit(result);
handleRateLimitHit(deploymentId, result);
}
return null;
});
Expand Down Expand Up @@ -145,13 +145,13 @@ private void setupProxyApiKeyData() {
ApiKeyData.initFromContext(proxyApiKeyData, context);
}

private void handleRateLimitHit(RateLimitResult result) {
private void handleRateLimitHit(String deploymentId, RateLimitResult result) {
// Returning an error similar to the Azure format.
ErrorData rateLimitError = new ErrorData();
rateLimitError.getError().setCode(String.valueOf(result.status().getCode()));
rateLimitError.getError().setMessage(result.errorMessage());
log.error("Rate limit error {}. Key: {}. User sub: {}. Trace: {}. Span: {}", result.errorMessage(),
context.getProject(), context.getUserSub(), context.getTraceId(), context.getSpanId());
log.error("Rate limit error {}. Key: {}. User sub: {}. Deployment: {}. Trace: {}. Span: {}", result.errorMessage(),
context.getProject(), context.getUserSub(), deploymentId, context.getTraceId(), context.getSpanId());
respond(result.status(), rateLimitError);
}

Expand Down

0 comments on commit 39ba0c6

Please sign in to comment.