Removes the deprecated `coder_aibridged_*` and `coder_aibridgeproxyd_*` Prometheus metric aliases, which were scheduled for removal in v2.37. The embedded AI Gateway and AI Gateway Proxy now emit only `coder_ai_gateway_*` and `coder_ai_gateway_proxy_*`. - Replace `NewMetricAliasRegisterer` with `prometheus.WrapRegistererWithPrefix` in `cli/server.go` and `enterprise/cli/aibridgeproxyd.go`. - Delete `coderd/prometheusmetrics/metricalias.go` and its test (no remaining callers). - Drop alias support from the metrics docs scanner. - Update the AI Gateway monitoring and rebranding migration docs: legacy names are removed as of v2.40. **Breaking:** dashboards and alerts that still use the legacy names stop matching. The monitoring docs show a temporary `metric_relabel_configs` bridge. Closes AIGOV-447. <details> <summary>Implementation plan</summary> | File | Change | |---|---| | `cli/server.go` | Remove the `TODO(deprecation)` comment; register embedded gateway metrics with `prometheus.WrapRegistererWithPrefix(aibridgemetrics.PrometheusMetricPrefix, ...)`. | | `enterprise/cli/aibridgeproxyd.go` | Same swap with the `coder_ai_gateway_proxy_` prefix; drop the unused `prometheusmetrics` import. | | `coderd/prometheusmetrics/metricalias.go`, `metricalias_test.go` | Delete; the two call sites above were the only callers. | | `scripts/metricsdocgen/scanner/prefix.go` | Remove `NewMetricAliasRegisterer` from `prefixFuncs`. | | `scripts/metricsdocgen/scanner/scanner_test.go` | Remove the alias fixture and the legacy-alias assertion; the remaining literal-prefix case already covers plain `WrapRegistererWithPrefix`. | | `scripts/metricsdocgen/README.md` | Drop the `NewMetricAliasRegisterer` mention. | | `docs/ai-governance/ai-gateway/monitoring.md` | State that legacy names are no longer emitted as of v2.40; reword the relabel snippet as a temporary bridge and explain its cost. | | `docs/ai-governance/ai-gateway/rebranding-migration.md` | Mark metrics as "No (removed in v2.40)"; rewrite the Metrics section; remove the now-obsolete "dropping the old names" section. | Release note: the `!` title applies `release/breaking`, so the change is listed under breaking changes in the v2.40 release notes. Verification: `make gen` (no metrics reference changes), `make lint`, `pnpm run format-docs`, `pnpm run lint-docs`, doc-check and test-audit self-review, and targeted tests for `enterprise/cli` (AI Gateway / proxy), `cli` (AI Gateway), `scripts/metricsdocgen`, and `coderd/prometheusmetrics`. </details> Code written by @mollymaefraser, with Coder Agents used as a guide.
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:
metrics(static, manually maintained)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 defined in Coder source code, such as:
go_*: Go runtime metricsprocess_*: Process metrics from prometheus/client_golangpromhttp_*: Prometheus HTTP handler metrics
Note
This file also supplies label metadata for source-defined metrics that the scanner cannot observe. For example,
coderd_agentstats_*labels are configured at runtime. When a metric appears in both files, its generated name, type, and description take priority, and the two label sets are unioned and deduplicated by name.
Edit this file to add metrics that should appear in the documentation but are not scanned from the Coder codebase, or to supply labels that only exist at runtime. Static labels are additive: an entry here can document a label the scanner cannot see, but it cannot remove or replace one the scanner found. To correct a label the scanner derives wrongly, fix the source declaration or the scanner, because a static entry will not override it. Do not add source-defined metrics solely because their registerer has a static prefix: the scanner resolves prefixes from prometheus.WrapRegistererWithPrefix.
generated_metrics (auto-generated)
Contains metrics extracted from 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
Configuring the scanner
Configure these options in scanner/scanner.go:
- Scan scope (
scanDirs): Directories searched recursively for metric definitions. Add a directory when definitions live outside the existing scan scope. Test files are excluded. - Prefix scope (
prefixScanDirs): Directories searched for registerer wrapping. The scanner resolves name prefixes fromprometheus.WrapRegistererWithPrefix, so prefixes do not need to be listed by hand. Add a directory when a registerer is wrapped outside the existing scope. - Exclusions (
excludeDirs): Subtrees excluded from scanning, for metrics a deployment never exposes. Document a metric in the static file instead when the scanner cannot extract it correctly.
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
metricsandgenerated_metricsmetric files - Update the documentation file