Files
cloudinit-bot 274253da3f feat(observability): T1.5 call-site wiring + per-run metrics.jsonl + runbook §4.5 (REQ-INB-20 + REQ-INB-23)
T2.2 closes the call-site wiring for the T1.5 Papra live-write gate
and lands the per-run metrics.jsonl surface (REQ-INB-23). The
T1.5 + T2.2 work is folded into one commit so the two pipeline
files are touched by exactly one Wave 2 task.

pipelines/common.py:
- LLM_METRICS_ENABLED env-var gate around the
  llm_call_seconds_sum / llm_call_count accumulators in
  _ollama_call_one_model. The accumulators are stored in
  os.environ so the main() functions can read them when emitting
  the per-run metrics line. Default is 'true' (gate enabled).

pipelines/live_pipeline.py:
- Import emit_papra_write_gate_event and emit_metric.
- process_one_message: emit the papra_write_gate event at the
  start of the papra branch (REQ-INB-20 call-site).
- main: emit one metrics line with the COUNTER_KEYS / GAUGE_KEYS
  vocabulary from pipelines/_metrics/emit.py, including
  llm_call_seconds_sum and llm_call_count read from the
  os.environ accumulators.

pipelines/historical_pipeline.py:
- Import emit_papra_write_gate_event and emit_metric.
- process_one_message: emit the papra_write_gate event at the
  start of the body-decision branch.
- main: emit one metrics line with the same vocabulary.

pipelines/_metrics/emit.py (new):
- emit_metric(run_id, pipeline, *, counters, gauges) appends one
  JSONL line to <pipeline>-metrics-<run_id>.jsonl. The
  COUNTER_KEYS and GAUGE_KEYS module constants pin the vocabulary
  so the test can assert exact equality.

pipelines/_metrics/__init__.py (new):
- Empty / near-empty package marker.

pipelines/_tests/test_metrics_offline.py (new, 2 tests):
- test_emit_metric_creates_file_with_one_line_per_call: asserts
  the line shape, the exact COUNTER_KEYS / GAUGE_KEYS, and the
  per-run file naming.
- test_emit_metric_does_not_overwrite_existing_file: asserts two
  calls in a row append, never truncate.

docs/operations-runbook.md:
- New §4.5 'Metrics surface' (after §4.4 'SeaweedFS bucket
  layout' at line 238). Documents the file location, the counter
  and gauge vocabulary, the tail-and-summarize procedure, the
  opt-out via LLM_METRICS_ENABLED, and a forward-pointer noting
  alerting is a v1.2 candidate (out of scope for v1.1).

---ci---
project: inboxos
phase: 1
milestone: v1.1
status: execute
---/ci---
2026-06-08 21:24:17 +00:00
..