Skip to content

feat: wave 2 — observability (telemetry, SSE logs, /metrics) - #21

Merged
wra-sol merged 1 commit into
mainfrom
feat/wave-2-observability
Jun 29, 2026
Merged

feat: wave 2 — observability (telemetry, SSE logs, /metrics)#21
wra-sol merged 1 commit into
mainfrom
feat/wave-2-observability

Conversation

@wra-sol

@wra-sol wra-sol commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Wave 2 of the opencode manager improvement plan. Three slices, one PR.

2.1 — Expose crash count, uptime, last-exit rc, restart history (closes #6)

ChildProcess now tracks started_at, last_exit_rc, last_exit_at, crash_count, and a restart_history deque (last 10 entries with timestamp, reason, and rc). These are surfaced in:

  • /manage/status JSON (new fields: pid, started_at, uptime_s, last_exit_rc, last_exit_at, crash_count, restarts)
  • Dashboard HTML (new rows: Uptime, Crashes, Last exit)

Restart reasons tracked: manual, crash, reconfigure, stopped.

2.2 — SSE log tail + manager events in ring + filter/search (closes #7)

  • Log ring broadened from 400 to 1000 entries, now captures both child stdout (plain strings) and manager events (dicts with ts, source, level, line).
  • Manager events logged: login success/failure (with IP), restart, key rotate, reconfigure, proxy errors, child crash/respawn/give-up.
  • New endpoint GET /manage/logs/stream — SSE stream that tails the log ring live.
  • Filter params: ?level=error, ?source=child or ?source=manager, ?q=<substring>.

2.3 — /metrics Prometheus endpoint (closes #8)

New endpoint GET /manage/metrics (session-auth required) emitting Prometheus text format:

Counters: requests_total{path}, login_attempts, login_failures, child_crashes, restarts_total{reason}, proxy_errors
Gauges: child_up, log_ring_size, uptime_seconds

Tests

11 new test cases. 119 total tests pass. Lint + format clean.

Wave 2.1 — Expose crash count, uptime, last-exit rc, restart history (closes #6)
- ChildProcess tracks started_at, last_exit_rc, last_exit_at, restart_history
- /manage/status returns pid, started_at, uptime_s, last_exit_rc, crash_count, restarts
- Dashboard shows uptime, crash count, last exit in the status card
- Restart history records reason (manual, crash, reconfigure, key-rotate) and rc

Wave 2.2 — SSE log tail + manager events + filter/search (closes #7)
- Log ring broadened to 1000 entries, now captures both child stdout (strings)
  and manager events (dicts with ts, source, level, line)
- Manager events logged: login success/failure, restart, key rotate, reconfigure,
  proxy errors, child crash/respawn
- New endpoint GET /manage/logs/stream — SSE tail with live updates
- Filter params on /manage/logs and /manage/logs/stream: ?level=, ?source=, ?q=
- /manage/logs returns structured entries (normalized to dicts for the API)
- Dashboard renders both string and dict log entries

Wave 2.3 — /metrics Prometheus endpoint (closes #8)
- New endpoint GET /manage/metrics (session-auth required)
- Counters: requests_total{path}, login_attempts, login_failures,
  child_crashes, restarts_total{reason}, proxy_errors
- Gauges: child_up, log_ring_size, uptime_seconds
- Metrics class with thread-safe increments
- Request counting in do_GET and do_POST

Tests: 11 new test cases. 119 total, all passing. Lint + format clean.
@wra-sol wra-sol added enhancement New feature or request wave-2 Wave 2: observability labels Jun 29, 2026
@wra-sol
wra-sol merged commit e09f4d1 into main Jun 29, 2026
8 checks passed
@wra-sol
wra-sol deleted the feat/wave-2-observability branch June 29, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request wave-2 Wave 2: observability

Projects

None yet

1 participant