← Back to PRs

#21915: Cron: add startup session reaper timing metrics

by mneves75 open 2026-02-20 14:35 View on GitHub →
docs size: S trusted-contributor
## Summary - add startup session reaper sweep timing metrics in `CronService.start()` - include aggregate counters (`storeCount`, `sweptStores`, `totalPruned`, `failedStores`, `elapsedMs`) and slowest-store timings (`slowestStorePath`, `slowestStoreElapsedMs`) - add regression coverage for disabled-cron startup sweep to assert metrics log payload - fix zero-duration edge case so `slowestStorePath` is populated when at least one store is swept - keep local run artifacts out of PR scope ## Verification - `pnpm exec vitest run src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts src/cron/session-reaper.test.ts src/cron/service.issue-regressions.test.ts src/config/sessions.cache.test.ts` - `pnpm exec oxlint src/cron/service/ops.ts src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts src/cron/service/timer.ts src/cron/service/reaper-paths.ts src/config/sessions/store.ts src/config/sessions.cache.test.ts` - `pnpm check` *(fails in this workspace at `format:check` because of large pre-existing unrelated formatting churn outside this patch)* ## Risk / compatibility - no schema/config/API surface changes - no behavior changes for cron job execution flow - adds one informational startup log line and startup sweep timing metadata only <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds startup session reaper timing metrics to `CronService.start()` and includes comprehensive error handling infrastructure improvements. **Main changes:** - Added timing metrics for session reaper sweep on startup (store count, pruned sessions, elapsed time, slowest store tracking) - Test coverage for disabled-cron startup sweep scenario validates metrics logging - Fixed zero-duration edge case ensuring `slowestStorePath` is populated when at least one store is swept **Additional changes (outside stated scope):** - Complete domain error hierarchy with `DomainError` base class and specific implementations (`ProviderConnectionError`, `ProviderAuthError`, `ValidationError`, etc.) - Result<T, E> pattern for railway-oriented programming - Comprehensive error handling documentation (495 lines in `docs/learn/10-error-handling.md`) - Android gateway server proposal documentation (3 new doc files) **Concerns:** The PR description focuses on cron metrics but includes substantial error handling refactoring and documentation that appears unrelated to the stated purpose. This bundling of unrelated changes makes review and rollback more difficult. <h3>Confidence Score: 3/5</h3> - Safe to merge but requires follow-up discussion about PR scope - The cron metrics implementation is well-tested and follows existing patterns. However, the PR bundles unrelated changes (error handling refactor, documentation) that weren't mentioned in the title or summary, making it harder to review atomically and increasing risk of unintended side effects - Review `src/infra/errors.ts` and `src/infra/unhandled-rejections.ts` for the error handling changes which appear unrelated to session reaper metrics <sub>Last reviewed commit: aa98ea6</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs