OpenCode Observability Stack¶
A self-contained observability stack for OpenCode, built on the
@devtheops/opencode-plugin-otel
plugin. Ships a Grafana dashboard with cost/token analytics, TraceQL-based explainability, and
a standalone session timeline (waterfall) explorer.
Prerequisites¶
- Docker with Docker Compose v2+
just(optional)- OpenCode with the
@devtheops/opencode-plugin-otelplugin - For local Trace Explorer development only (
just dev-trace-explorer):uvand Node.js 22+
Features¶
- Cost & token analytics — usage by model, agent, and session; breakdown by token type
- Tool usage — call counts, average duration, and success rate per tool
- Productivity — lines added/removed, message counts per session
- TraceQL tables — LLM calls (prompt → model → outcome) and tool calls (tool → params → result)
- Trace → Logs linking — click a span in Grafana to jump to matching Loki logs
- Trace Explorer — React/FastAPI waterfall SPA with session timelines, subagent linking, and a cross-session usage dashboard
- Dashboard filters —
session_id,model, andagenttemplate variables apply to every panel
Where to go next¶
- Architecture — how the services fit together
- Quick Start — start the stack and connect OpenCode
- Metrics, Logs & Traces — what's exported and how to query it
- Dashboard — the Grafana "OpenCode Observability" dashboard
- Trace Explorer — waterfall session timeline + cross-session usage dashboard
- Configuration — collector, Tempo, and Grafana datasource details
- Development —
justtargets and local dev workflow