Repository navigation
List recent failures under each failure count on /ui/analytics - #439
Conversation
- Failure recorders take a FailureDetail: PURL, filename, URL, storage path, error - Keep the last 20 failures per counter series in memory, reset on restart - Strip userinfo, query and fragment from URLs, including those inside error text - Pass the detail from upstream, storage, integrity, health probe and scan call sites - Package names and URLs stay out of Prometheus labels
- Add ui_failure_details / PROXY_UI_FAILURE_DETAILS, off by default - Each failure row expands to its latest failures, newest first - Show a note naming the config key when failures exist and the flag is off - Document the flag in README, configuration reference and example config
56f13bc to
496f272
Compare
andrew
left a comment
There was a problem hiding this comment.
Please isolate the process-global recent failure history in the new tests. Cleanup alone does not prevent records from earlier tests or earlier repetitions from reaching these assertions.
go test ./internal/server -run '^TestRuntimeViewAttachesRecentFailuresWhenEnabled$' -count=2 fails on the second run at analytics_failures_test.go:38: it finds two recent failures instead of one.
go test ./internal/metrics -run '^Test(RecordUpstreamOperations|RecentFailuresNewestFirst)$' -count=2 fails at failures_test.go:20: it finds three failures instead of two because TestRecordUpstreamOperations leaves a record behind.
Reset or isolate the history before assertions and clean up every test that writes it, so repeated runs and changes in test order remain reliable.
The history is process-wide, and tests cleared it only after running, and not all of them. Records from earlier tests or an earlier -count repetition reached later assertions: TestRecordUpstreamOperations left a record for TestRecentFailuresNewestFirst, and the server tests never cleared it. - Export ResetRecentFailures so tests outside the metrics package can use it - Clear the history before and after every test that records or reads failures directly, in metrics, server and handler - Assert exactly one failure in the handler tests instead of looking only at the newest
|
Confirmed both, and fixed in b131db3. Tests only cleared the history after running, and not all of them did.
Both of your commands now pass, and so does |
The failure counts under Runtime on
/ui/analyticssay how often something failed, but not what. Whennpm · fetch_failedshows 7, there is no way to see which packages failed without digging through the logs.This adds an expandable Latest N list under each failure count, newest first. Each entry shows the package URL, the filename, the upstream URL or storage path, the error, and how long ago it happened.
Changes
RecordUpstreamError,RecordStorageError,RecordIntegrityFailure,RecordHealthProbeFailureandRecordScanErrortake ametrics.FailureDetail(PURL, filename, URL, path, error). All existing call sites pass what they already have in scope.Get "https://user:token@…?sig=…").ui_failure_details/PROXY_UI_FAILURE_DETAILS, off by default for the same reason asui_request_sources:/uihas no authentication. While it is off and failures exist, the page shows a note naming the setting.docs/configuration.mdandconfig.example.yaml.Circuit-breaker trips and blocked scans are left as they are: their call sites have no per-failure detail beyond the labels.
Testing
metrics.ResetRecentFailures). The tests pass with-count=2and withgo test -count=3 -shuffle=on ./internal/metrics ./internal/server ./internal/handler.go test -race,go vetandgolangci-lintv2.13.1 pass.left-padtarball; thenpm · fetch_failedrow expands topkg:npm/left-pad@99.99.99, its registry URL, andartifact not found.