feat: wave 2 — observability (telemetry, SSE logs, /metrics) - #21
Merged
Conversation
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.
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.
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)
ChildProcessnow tracksstarted_at,last_exit_rc,last_exit_at,crash_count, and arestart_historydeque (last 10 entries with timestamp, reason, and rc). These are surfaced in:/manage/statusJSON (new fields:pid,started_at,uptime_s,last_exit_rc,last_exit_at,crash_count,restarts)Restart reasons tracked:
manual,crash,reconfigure,stopped.2.2 — SSE log tail + manager events in ring + filter/search (closes #7)
ts,source,level,line).GET /manage/logs/stream— SSE stream that tails the log ring live.?level=error,?source=childor?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.