Documentation
¶
Overview ¶
Package metrics provides system and LLM usage metrics for tmux-webui.
Overview ¶
The package defines a Provider interface and a Snapshot value type. Two concrete providers are available:
StubProvider: always returns an empty Snapshot; used by default in v0 to avoid introducing a gopsutil dependency before it is needed.
HTTPProvider: fetches a JSON payload from a configurable URL (e.g. http://127.0.0.1:10103/sysmon/current from the agent-metrics station) and maps the display fields onto Snapshot. Parsing logic mirrors the Python status_metrics() function in tmux_manager.py.
Configuration ¶
// from config.MetricsConfig
if cfg.Metrics.Provider == "http" && cfg.Metrics.URL != "" {
prov = metrics.NewHTTP(cfg.Metrics.URL)
} else {
prov = metrics.NewStub()
}
LLM key convention ¶
The sysmon JSON can contain keys of the form llm_{provider}_{metric} (e.g. llm_cc_5h, llm_gm_pro). HTTPProvider groups these into a nested map[provider]map[metric]value, dropping empty / "?" values. The key llm_display is explicitly excluded.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
Provider collects a Snapshot on demand. Implementations must be safe for concurrent use and must never block indefinitely — callers hold locks or are inside a ticker goroutine.
func NewHTTP ¶
NewHTTP returns a Provider that fetches metrics from the given URL. url should be the sysmon/current endpoint, e.g. "http://127.0.0.1:10103/sysmon/current".
type Snapshot ¶
type Snapshot struct {
Net string `json:"net,omitempty"`
CPU string `json:"cpu,omitempty"`
Mem string `json:"mem,omitempty"`
Disk string `json:"disk,omitempty"`
LLM map[string]map[string]string `json:"llm,omitempty"`
}
Snapshot holds a point-in-time view of system and LLM usage metrics. All string fields use the pre-formatted display strings produced by the agent-metrics sysmon endpoint — ready to render in the UI as-is.
Fields are omitted from JSON when empty so the WebSocket payload stays lean.