mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-23 06:07:47 +00:00
feat(admin): add events feed, fleet-wide rejections and span rankings
GET /admin/api/events returns recent failures, newest first. It covers rate limits, budget and unpriced-model refusals, upstream errors, timeouts and capacity rejections. Events go into an in-process ring of 200 entries and are copied to a Redis list (llmgw:events, LPUSH plus LTRIM to 200). The copy happens only on the error path, is throttled to 50 per second per replica, and never blocks a request. When Redis is absent or down, the feed falls back to this replica's ring. Messages are fixed strings or scrubbed provider errors. Fields are assigned one at a time, because Yaegi drops values from a multi-value assignment that contains a call. Rejections per day are counted per scope and in total, in the same store call that already rolls back a rejected request. /admin/api/usage returns them as rejectionsPerDay. /admin/api/usage/models accepts span, which sums that many buckets, and prefix, which filters model ids before the limit applies. The overview reports the replica id, the instance name and the warnings logged while the middleware was built. The failover and retry fan-out warning is now logged at WARN. Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
+4
-4
@@ -55,11 +55,11 @@ var anthropicPassthroughForwardedHeaders = []string{"anthropic-beta"}
|
||||
// {"error":{...}} — see writeAnthropicError and its callers, below).
|
||||
//
|
||||
// ORDERING (item 2 fix, 2026-08-22 review): body admission + decode run
|
||||
// BEFORE admitRequest (the rate-limit check) on THIS route — the
|
||||
// BEFORE admitRequestForRoute (the rate-limit check) on THIS route — the
|
||||
// opposite order from runUnified's own finding 1a. anthropic-sdk-python
|
||||
// retries any status >= 500, and Claude Code streams on every call: the
|
||||
// previous ordering (admitRequest first, streaming rejected only after
|
||||
// decode) meant every real client hitting this not-yet-streaming-capable
|
||||
// previous ordering (admitRequestForRoute first, streaming rejected only
|
||||
// after decode) meant every real client hitting this not-yet-streaming-capable
|
||||
// route burned three requests of rate-limit budget per logical call —
|
||||
// verified repro: requestsPerMinute 2, three attempts -> 501, 501, 429,
|
||||
// day counter reads 3. Deciding "is this streaming" requires the decoded
|
||||
@@ -103,7 +103,7 @@ func (g *Gateway) handleMessages(w http.ResponseWriter, r *http.Request, u *user
|
||||
return
|
||||
}
|
||||
|
||||
scopes, ok := g.admitRequest(sw, u, grp, writeAnthropicError)
|
||||
scopes, ok := g.admitRequestForRoute(sw, u, grp, writeAnthropicError, routeMessages)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user