fix(o11y): sample floors for the 5xx and LiteLLM error-rate alerts - #398
Merged
Merged
Conversation
api-5xx-rate now needs 100 requests in its 15 minute window and litellm-error-rate 20 non-denied calls in its hour, the smallest totals at which a single error cannot exceed the 1 % and 5 % thresholds. Below the floor the rule is not firing, so an active alert resolves through the existing path. Continues #390. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
A deliberate production probe on 2026-09-30 showed
api-5xx-ratecan page on a single 500 at low traffic, because it has no minimum sample. This continues #390 (which added sample floors topreview-ready-rateandsession-start-p95) and the alert-accuracy follow-up DEV-3143, without claiming to close it. I audited every rule inrunner/workers/o11y/src/alerts/rules.tsand added a floor only to the two ratio rules that could fire on one event:api-5xx-rate(newFIVE_XX_MIN_REQUESTS = 100on the adjusted total, 15 min window) andlitellm-error-rate(newLITELLM_MIN_CALLS = 20non-denied calls, 1 h window). The floors follow one principle: the smallest total at which a single error cannot exceed the threshold (1 error / 100 = 1 %, not above 1 %; 1 / 20 = 5 %, not above 5 %). Below a floor the rule is simply not firing, so an active alert resolves through the existing notify path, and the detail text says the sample is below the floor. At roughly 60 requests per minute (about 900 per 15 min) the 5xx floor will rarely bind in busy hours. No SQL changed. ADR-0041 section F.3 is updated; no other doc lists these thresholds.Audit of every rule:
Types of changes
runner/) changeHow was this verified?
Tests in
runner/pipeline/o11y-alerts.test.mjscover, for each changed rule, below the floor (not firing even at 100 % bad), one error exactly at the floor (not firing), at the floor above the threshold (fires), above the floor healthy (not firing), and the resolve path when a firing alert drops below the floor; the 5xx floor is also shown to use the adjusted total and the LiteLLM floor to ignore denied calls. Existing tests already seeded at least the floor, so none needed re-seeding. Revert proof: withrules.tschecked out from the base commit (23ebd18) the 6 new tests fail (3 per rule) and the other 81 pass; neutralising only the two floor guards fails the same 6. Runs:node --experimental-strip-types --test pipeline/*.test.mjs2581 pass, 0 fail;tsc --noEmitclean inworkers/o11yandworkers/api;pnpm --filter @handsontable/demo-runtime buildok;wrangler deploy --dry-run --containers-rollout=noneinworkers/o11yok (plain dry-run needs Docker, which is not running locally). The fake AE engine only proves the SQL passes the guard, not that Analytics Engine accepts it. Nothing here was validated in production or against a live Analytics Engine.Checklist
pnpm build(andpnpm dev) in the affected example/server-example locally: not applicable, no example changed; runner checks are listed aboveRelated issue(s):
Note
Low Risk
Alert logic only tightens false-positive paging on low traffic; thresholds and windows are unchanged once sample floors are met, with tests covering resolve behavior.
Overview
Adds minimum sample floors to the two ratio-based o11y alerts that could page on a single error at low traffic, following the same pattern as preview-ready and session-start-p95 (#390).
api-5xx-ratenow requires at least 100 adjustedapi.requestsamples in the 15-minute window (after deliberate 5xx exclusions) before the >1% threshold is evaluated; one isolated 500 no longer fires the rule.litellm-error-raterequires at least 20 non-deniedgateway calls in the hour before the >5% threshold applies. Below each floor the rule is treated as not firing (so an active alert resolves normally), and rule detail text explains the shortfall.ADR-0041 §F.3 documents the new floors.
pipeline/o11y-alerts.test.mjsadds coverage for boundary behavior, adjusted totals / denied exclusion, and fire→resolve when volume drops under the floor. No Analytics Engine SQL changes.Reviewed by Cursor Bugbot for commit 0afd0b3. Bugbot is set up for automated code reviews on this repo. Configure here.