[loop-generated] [feature] Provider health history endpoint #457

Closed
opened 2026-03-19 18:38:22 +00:00 by Timmy · 1 comment
Owner

What

Time-series provider health data for dashboard visualization.

Why

CascadeRouter only exposes current snapshots. No history.

Acceptance criteria

  • GET /api/v1/router/history?hours=24
  • Timestamped snapshots of provider status/latency/error rate
  • SQLite storage, background task every 60s
  • Unit tests

Files

  • src/infrastructure/router/history.py (new)
  • src/infrastructure/router/api.py
  • tests/infrastructure/test_router_history.py (new)
## What Time-series provider health data for dashboard visualization. ## Why CascadeRouter only exposes current snapshots. No history. ## Acceptance criteria - GET /api/v1/router/history?hours=24 - Timestamped snapshots of provider status/latency/error rate - SQLite storage, background task every 60s - Unit tests ## Files - src/infrastructure/router/history.py (new) - src/infrastructure/router/api.py - tests/infrastructure/test_router_history.py (new)
Author
Owner

Implementation Instructions\n\n1. Create src/infrastructure/router/history.py:\n - HealthRecorder class with SQLite backend (use data/router_health.db)\n - Background async task (every 60s) that snapshots current provider status from CascadeRouter\n - Store: timestamp, provider_name, is_healthy, latency_ms, error_rate, circuit_state\n - get_history(hours=24) method returning list of snapshots\n\n2. Add endpoint in src/infrastructure/router/api.py:\n - GET /api/v1/router/history?hours=24\n - Returns JSON array of timestamped health records\n\n3. Tests in tests/infrastructure/test_router_history.py:\n - Test recording snapshots\n - Test retrieval with time filtering\n - Test SQLite creation\n\nKeep it simple. Use aiosqlite or plain sqlite3. The CascadeRouter already has get_metrics() — use that as the data source.

## Implementation Instructions\n\n1. Create `src/infrastructure/router/history.py`:\n - `HealthRecorder` class with SQLite backend (use `data/router_health.db`)\n - Background async task (every 60s) that snapshots current provider status from CascadeRouter\n - Store: timestamp, provider_name, is_healthy, latency_ms, error_rate, circuit_state\n - `get_history(hours=24)` method returning list of snapshots\n\n2. Add endpoint in `src/infrastructure/router/api.py`:\n - `GET /api/v1/router/history?hours=24`\n - Returns JSON array of timestamped health records\n\n3. Tests in `tests/infrastructure/test_router_history.py`:\n - Test recording snapshots\n - Test retrieval with time filtering\n - Test SQLite creation\n\nKeep it simple. Use aiosqlite or plain sqlite3. The CascadeRouter already has `get_metrics()` — use that as the data source.
kimi was assigned by Timmy 2026-03-19 18:54:54 +00:00
kimi was unassigned by Timmy 2026-03-20 20:02:23 +00:00
hermes was assigned by Timmy 2026-03-20 20:02:23 +00:00
Timmy closed this issue 2026-03-20 20:09:22 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#457