feat: wave 2 — observability (telemetry, SSE logs, /metrics) - #20
Closed
wra-sol wants to merge 1 commit into
Closed
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. Based on Wave 1 (PR #19).
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. Sends the current filtered ring as an initial burst, then appends new entries as they arrive (polls at 0.5s)./manage/logsand/manage/logs/stream:?level=error,?source=childor?source=manager,?q=<substring>./manage/logsreturns structured entries (child stdout normalized to dicts for the API).2.3 — /metrics Prometheus endpoint (closes #8)
New endpoint
GET /manage/metrics(session-auth required) emitting Prometheus text format:Counters (monotonic, process-lifetime):
opencode_railway_requests_total{path}opencode_railway_login_attempts_totalopencode_railway_login_failures_totalopencode_railway_child_crashes_totalopencode_railway_restarts_total{reason}opencode_railway_proxy_errors_totalGauges:
opencode_railway_child_up(1|0)opencode_railway_log_ring_sizeopencode_railway_uptime_secondsMetricsclass with thread-safe increments. Request counting indo_GETanddo_POST.Tests
11 new test cases:
119 total tests pass.
ruff check+ruff format --checkclean.