Files
coder/scripts/metricsdocgen
Cian Johnston a876287d36 feat: auto-archive inactive chats with audit trail (#24642)
Adds a background job in `dbpurge` that periodically archives chats
inactive beyond a configurable threshold. Each archived root chat gets a
background audit entry tagged `chat_auto_archive`. Disabled by default.

* New `AutoArchiveInactiveChats` SQL query with LATERAL last-activity
subquery and partial index on archive candidates
* `site_configs`-backed `auto_archive_days` setting with admin-only PUT,
any-authenticated-user GET
* Cascade archive via `root_chat_id`; pinned chats and active threads
exempt
* Root-only audit dispatch on detached context, matching manual archive
(`patchChat`) behavior
* 11 subtests covering disabled no-op, boundary, deleted messages, child
activity, pinned exemption, multi-owner, idempotency, and batch
pagination

PR #24643 adds per-owner digest notifications.
PR #24704 adds the requisite UI controls.

> 🤖
2026-04-24 14:18:28 +01:00
..

Metrics Documentation Generator

This tool generates the Prometheus metrics documentation at docs/admin/integrations/prometheus.md.

How It Works

The documentation is generated from two metrics files:

  1. metrics (static, manually maintained)
  2. generated_metrics (auto-generated, do not edit)

These files are merged and used to produce the final documentation.

metrics (static)

Contains metrics that are not directly defined in the coder source code:

  • go_*: Go runtime metrics
  • process_*: Process metrics from prometheus/client_golang
  • promhttp_*: Prometheus HTTP handler metrics
  • coder_aibridged_*: Metrics from external dependencies

Note

This file also contains edge cases where metric metadata cannot be accurately extracted by the scanner (e.g., labels determined by runtime logic). Static metrics take priority over generated metrics when both files contain the same metric name.

Edit this file to add metrics that should appear in the documentation but are not scanned from the coder codebase, or to manually override metrics where the scanner generates incorrect metadata (e.g., missing runtime-determined labels like in agent_scripts_executed_total).

generated_metrics (auto-generated)

Contains metrics extracted from the coder source code by the AST scanner (scanner/scanner.go).

Do not edit this file directly. It is regenerated by running:

make scripts/metricsdocgen/generated_metrics

Updating Metrics Documentation

To regenerate the documentation after code changes:

make docs/admin/integrations/prometheus.md

This will:

  • Run the scanner to update generated_metrics
  • Merge metrics and generated_metrics metric files
  • Update the documentation file