This PR adds traces for when users hit LLM rate limits. We were already emitting telemetry events for these to Clickhouse, but it will be handy to have them available in Axiom as well. Release Notes: - N/A
Unified · Split
| @@ -463,6 +463,24 @@ async fn check_usage_limit( · 462 unmodified lines | ||
| 463 | 463 | }; |
| 464 | 464 | |
| 465 | 465 | if let Some(client) = state.clickhouse_client.as_ref() { |
| 466 | + tracing::info!( | |
| 467 | + target: "user rate limit", | |
| 468 | + user_id = claims.user_id, | |
| 469 | + login = claims.github_user_login, | |
| 470 | + authn.jti = claims.jti, | |
| 471 | + is_staff = claims.is_staff, | |
| 472 | + provider = provider.to_string(), | |
| 473 | + model = model.name, | |
| 474 | + requests_this_minute = usage.requests_this_minute, | |
| 475 | + tokens_this_minute = usage.tokens_this_minute, | |
| 476 | + tokens_this_day = usage.tokens_this_day, | |
| 477 | + users_in_recent_minutes = users_in_recent_minutes, | |
| 478 | + users_in_recent_days = users_in_recent_days, | |
| 479 | + max_requests_per_minute = per_user_max_requests_per_minute, | |
| 480 | + max_tokens_per_minute = per_user_max_tokens_per_minute, | |
| 481 | + max_tokens_per_day = per_user_max_tokens_per_day, | |
| 482 | + ); | |
| 483 | + | |
| 466 | 484 | report_llm_rate_limit( |
| 467 | 485 | client, |
| 468 | 486 | LlmRateLimitEventRow { |