collab: Report when upstream rate limit is exceeded (#17083)
This PR makes it so we report a trace when the upstream rate limit is exceeded. Release Notes: - N/A
This commit is contained in:
parent
6d3fbc4123
commit
d666cc5fba
1 changed files with 16 additions and 4 deletions
|
@ -237,10 +237,22 @@ async fn perform_completion(
|
||||||
.await
|
.await
|
||||||
.map_err(|err| match err {
|
.map_err(|err| match err {
|
||||||
anthropic::AnthropicError::ApiError(ref api_error) => match api_error.code() {
|
anthropic::AnthropicError::ApiError(ref api_error) => match api_error.code() {
|
||||||
Some(anthropic::ApiErrorCode::RateLimitError) => Error::http(
|
Some(anthropic::ApiErrorCode::RateLimitError) => {
|
||||||
StatusCode::TOO_MANY_REQUESTS,
|
tracing::info!(
|
||||||
"Upstream Anthropic rate limit exceeded.".to_string(),
|
target: "upstream rate limit exceeded",
|
||||||
),
|
user_id = claims.user_id,
|
||||||
|
login = claims.github_user_login,
|
||||||
|
authn.jti = claims.jti,
|
||||||
|
is_staff = claims.is_staff,
|
||||||
|
provider = params.provider.to_string(),
|
||||||
|
model = model
|
||||||
|
);
|
||||||
|
|
||||||
|
Error::http(
|
||||||
|
StatusCode::TOO_MANY_REQUESTS,
|
||||||
|
"Upstream Anthropic rate limit exceeded.".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
Some(anthropic::ApiErrorCode::InvalidRequestError) => {
|
Some(anthropic::ApiErrorCode::InvalidRequestError) => {
|
||||||
Error::http(StatusCode::BAD_REQUEST, api_error.message.clone())
|
Error::http(StatusCode::BAD_REQUEST, api_error.message.clone())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue