// CONTENTS Part 10 · Testing, quality, observability

// PART 10

Logging, metrics, SLOs, and tracing

Chapter 44 / 56 3 min read English Part 10 of 14

Observability in General Bots is two systems: the component-level monitoring stack (crates that collect metrics, alert and trace), and the run-level observability built into the chat engine (spans, events, budgets). This page describes both, with the retention and restart contracts stated exactly.

Run-level observability (the chat engine)

Every chat turn can be observed as a run. The machinery lives in botserver/src/core/bot/runs/:

Piece What it holds Persistence
Trace buffer (observability.rs) in-flight spans per run volatile until finish_run; finished spans land in agent_spans, summaries in agent_runs
Event frames (store.rs) ordered run_events per thread PostgreSQL, retention GB_RUN_EVENTS_RETENTION_DAYS (30 days), reclaimed by a background task
Stale reconciliation running/pending rows older than GB_STALE_RUN_MINUTES (15) reconciled to interrupted at boot and lazily
Run thread bus (bus.rs) live subscribers and steering volatile; clients resume from run_events via the session resume path
SLO budgets bottest/tests/slo_budget_test.rs asserted in the test suite

Read it with SQL:

SELECT status, count(*) FROM agent_runs GROUP BY status;
SELECT * FROM run_events WHERE thread_id = '<thread>' ORDER BY seq;

Component-level monitoring

The botmonitoring crate provides metrics collection, alerting and distributed tracing; botanalytics covers product analytics (insights, OKR goals, reporting); bottimeseries is the InfluxDB-compatible time-series service. The suite’s monitoring app surfaces views over them (/ws/logs streams monitoring logs).

Signal Source
Request/error metrics botmonitoring
Turn spans and events agent_spans, run_events
Usage/engagement botanalytics
Time-series metrics bottimeseries
Client-side errors botserver logs, CLIENT: prefix
Drive/monitor activity botserver logs, [drive_monitor] prefix

Log locations

Component Where
botserver (dev) botserver.log (API requests, errors, script execution, client events)
botui botui.log
Container services journalctl -u <service> inside the instance (systemctl units per component)
CI runs zstd logs in the alm container, filename tracked in PROD-ALM

Error triage starts the same way every time:

grep -E " E | W " botserver.log | tail -20
grep -E "ERROR|WARN|drive_monitor" botserver.log | tail -20

The state contract after a restart

A restart is an observability event worth understanding. The documented dispositions:

State Disposition
Published-file ledger Redis mirror, memory fallback (TTL in days)
Run trace buffer volatile; flushed on finish
Run events durable in PostgreSQL, reclaimed after retention
Stale runs reconciled to interrupted at boot
Sandbox previews volatile with reason codes (fresh / expired / interrupted_by_restart)
Suggestion keys, counters volatile; rebuilt from durable sources

Only the durable rows are authoritative for state that outlives a process; anything volatile is rebuilt or expires, and the code marks which is which.

Health checks

Check Meaning
GET /health process up (8080 dev / 5858 container)
Bootstrap completion “Bootstrap process completed!” in the server log
Drive monitors [drive_monitor] lines showing bucket sync
Clean boot no E lines after startup; a fresh boot should be silent

Practical SLOs

SLO budgets are enforced in tests (slo_budget_test.rs) rather than promised in prose. When a budget fails, the fix is a code change or an explicit budget decision — not a loosened assertion.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move