Field notes
2026-07-08 — Per-channel token and model metrics
Context: Token consumption was previously aggregated strictly by kind (input/output/cache_read/cache_creation). To enable downstream cost calculation (e.g., in Grafana), the metrics needed granularity down to the specific Slack channel and the active LLM model.
Decision:
Augment the slaude_tokens_total Prometheus counter with two new labels: channel_id and model.
Mechanism:
manager.tsfetches the activeslack_channel_idfrom the SQLite session store using thesessionIdwhen the SDK yields aresult.- Extracts the active model from the SDK message, falling back to
SLAUDE_MODEL. - Passes
{ channel_id, model, kind }tometrics.tokensTotal.inc(). - Exposing the model and channel labels allows downstream aggregators to multiply token counts by per-model rates to estimate cost accurately without hardcoding pricing within the slaude runtime.