feat: add Prometheus metrics for chatd subsystem (#24371)

Adds 7 Prometheus metrics to the chatd subsystem and introduces typed
`ActivityBumpReason` for deadline bump attribution.

| Metric | Type | Labels |
|--------|------|--------|
| `coderd_chatd_chats` | Gauge | `state` (streaming, waiting) |
| `coderd_chatd_message_count` | Histogram | `provider` |
| `coderd_chatd_prompt_size_bytes` | Histogram | `provider` |
| `coderd_chatd_tool_result_size_bytes` | Histogram | `provider`,
`tool_name` |
| `coderd_chatd_ttft_seconds` | Histogram | `provider` |
| `coderd_chatd_compaction_total` | Counter | `provider`, `result` |
| `coderd_chatd_steps_total` | Counter | `provider` |

> 🤖
This commit is contained in:
Cian Johnston
2026-04-15 19:53:10 +01:00
committed by GitHub
parent 2b68a1f4bd
commit d7439a9de0
13 changed files with 644 additions and 13 deletions
+21
View File
@@ -226,6 +226,27 @@ coderd_authz_prepare_authorize_duration_seconds 0
# HELP coderd_build_info Describes the current build/version of the Coder server. Value is always 1.
# TYPE coderd_build_info gauge
coderd_build_info{version="",revision=""} 0
# HELP coderd_chatd_chats Number of chats being processed, by state.
# TYPE coderd_chatd_chats gauge
coderd_chatd_chats{state=""} 0
# HELP coderd_chatd_compaction_total Total compaction outcomes (only recorded when compaction was triggered or failed).
# TYPE coderd_chatd_compaction_total counter
coderd_chatd_compaction_total{provider="",result=""} 0
# HELP coderd_chatd_message_count Number of messages in the prompt per LLM request.
# TYPE coderd_chatd_message_count histogram
coderd_chatd_message_count{provider=""} 0
# HELP coderd_chatd_prompt_size_bytes Estimated byte size of the prompt per LLM request.
# TYPE coderd_chatd_prompt_size_bytes histogram
coderd_chatd_prompt_size_bytes{provider=""} 0
# HELP coderd_chatd_steps_total Total agentic loop steps across all chats.
# TYPE coderd_chatd_steps_total counter
coderd_chatd_steps_total{provider=""} 0
# HELP coderd_chatd_tool_result_size_bytes Size in bytes of each tool execution result.
# TYPE coderd_chatd_tool_result_size_bytes histogram
coderd_chatd_tool_result_size_bytes{provider="",tool_name=""} 0
# HELP coderd_chatd_ttft_seconds Time-to-first-token: wall time from LLM request to first streamed chunk.
# TYPE coderd_chatd_ttft_seconds histogram
coderd_chatd_ttft_seconds{provider=""} 0
# HELP coderd_db_query_counts_total Total number of queries labelled by HTTP route, method, and query name.
# TYPE coderd_db_query_counts_total counter
coderd_db_query_counts_total{route="",method="",query=""} 0