Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(scripts/metricsdocgen): add prometheus.NewDesc() pattern to metrics scanner - #21461

Merged
ssncferreira merged 2 commits into
mainfrom
ssncferreira/metricsdocgen-ast-scanner-newdesc
Feb 13, 2026
Merged

feat(scripts/metricsdocgen): add prometheus.NewDesc() pattern to metrics scanner#21461
ssncferreira merged 2 commits into
mainfrom
ssncferreira/metricsdocgen-ast-scanner-newdesc

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements extraction of metrics defined using the prometheus.NewDesc() pattern.

Changes

  • Add extractNewDescMetric() to extract metrics from prometheus.NewDesc() calls
  • Script generates an updated scripts/metricsdocgen/generated_metrics file

Related to: #13223

Disclosure: This PR was mainly developed with Claude Sonnet 4, with iterative review and refinement by @ssncferreira

@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from 95bcc37 to c3053d7 Compare January 8, 2026 21:22
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from f64fdaf to d2a562c Compare January 8, 2026 21:22
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from c3053d7 to c591965 Compare January 9, 2026 08:51
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from d2a562c to 4340913 Compare January 9, 2026 08:51
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from c591965 to d253ee8 Compare January 9, 2026 08:52
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch 3 times, most recently from b52d9eb to 44b7bba Compare January 9, 2026 09:47
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch 2 times, most recently from b487f0c to aee2d85 Compare January 9, 2026 10:37
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch 2 times, most recently from 70d2452 to a14ee38 Compare January 9, 2026 10:38
@ssncferreira ssncferreira changed the title feat(scripts): add prometheus.NewDesc() pattern to metrics scanner feat(scripts/metricsdocgen): add prometheus.NewDesc() pattern to metrics scanner Jan 9, 2026
@ssncferreira
ssncferreira marked this pull request as ready for review January 9, 2026 11:32
// Example:
// - "coderd_" + "api_" + "requests": "coderd_api_requests"
// - namespace + "_" + metricName: resolved concatenation
func resolveBinaryExpr(expr *ast.BinaryExpr, decls declarations) string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh... I trust you that it works the right way, although some tests would be helpful.

@ssncferreira ssncferreira Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but unfortunately didn't have time for tests. Tthis is currently working as seen by the generated file: scripts/metricsdocgen/generated_metrics. But yes, tests would be great for future metric changes on the codebase.

@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from aee2d85 to b8b4331 Compare January 16, 2026 19:01
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from a14ee38 to 7464012 Compare January 16, 2026 19:01
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from b8b4331 to c6638df Compare January 23, 2026 19:18
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from 7464012 to 0462360 Compare January 23, 2026 19:18
@github-actions

Copy link
Copy Markdown
Contributor

@coderagents

coderagents Bot commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

No Changes Needed

This PR enhances the internal metrics scanner tool (scripts/metricsdocgen) to extract metrics from prometheus.NewDesc() patterns. The generated metrics file is used internally to auto-generate the metrics table in docs/admin/integrations/prometheus.md.

Since the PR updates the code generation tool (not user-facing features), and the generated metrics are already documented via the auto-generated table at lines 105-199 of docs/admin/integrations/prometheus.md, no documentation changes are needed.

The newly extracted metrics (pubsub, insights, license, and prebuilt workspace metrics) are already present in the generated table in the documentation.


Automated review via Coder Tasks

@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from c6638df to a370b3f Compare January 28, 2026 08:57
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from 0462360 to 2caf0ad Compare January 28, 2026 08:57
@coderagents

coderagents Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Previous Feedback

The previous review stated metrics were already documented, but this was inaccurate. The metrics will be documented when the stack completes.

No Changes Needed (for this PR)

This PR (#21461) is part of a stack that implements automatic metrics documentation generation:

The newly extracted metrics in scripts/metricsdocgen/generated_metrics include:

  • coder_pubsub_* (6 metrics)
  • coderd_insights_* (3 metrics)
  • coderd_license_* (3 metrics)
  • coderd_prebuilt_workspaces_* (11 metrics)

These metrics are not yet in the documentation because:

  1. The current docs/admin/integrations/prometheus.md is generated from scripts/metricsdocgen/metrics (not generated_metrics)
  2. PR chore: integrate metrics scanner into Makefile #21465 will update the Makefile to use the scanner output
  3. Documentation will be auto-generated when make docs/admin/integrations/prometheus.md runs after the stack merges

No documentation changes needed in this PR - the infrastructure PR is working as designed. The documentation will be automatically updated by the build process once the full stack lands.


Automated review via Coder Tasks

@github-actions github-actions Bot added the stale This issue is like stale bread. label Feb 5, 2026
@ssncferreira ssncferreira removed the stale This issue is like stale bread. label Feb 6, 2026
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from a370b3f to ca70f52 Compare February 12, 2026 15:57
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch 3 times, most recently from 2b637bb to fd7a05c Compare February 12, 2026 16:58
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from 65dbf29 to 0f1be8c Compare February 12, 2026 16:58
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from fd7a05c to a65ba82 Compare February 12, 2026 17:22
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from 0f1be8c to 1bdb883 Compare February 12, 2026 17:23
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from a65ba82 to 1ada5a6 Compare February 12, 2026 17:23
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-core branch from 1bdb883 to f7f0213 Compare February 13, 2026 10:20
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from 36ce1aa to 27c0d16 Compare February 13, 2026 10:20

ssncferreira commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Feb 13, 10:48 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 13, 10:50 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 13, 11:01 AM UTC: @ssncferreira merged this pull request with Graphite.

@ssncferreira
ssncferreira changed the base branch from ssncferreira/metricsdocgen-ast-scanner-core to graphite-base/21461 February 13, 2026 10:48
@ssncferreira
ssncferreira changed the base branch from graphite-base/21461 to main February 13, 2026 10:49
@ssncferreira
ssncferreira force-pushed the ssncferreira/metricsdocgen-ast-scanner-newdesc branch from 27c0d16 to f0cb7f3 Compare February 13, 2026 10:49
@ssncferreira
ssncferreira merged commit 45280d5 into main Feb 13, 2026
33 checks passed
@ssncferreira
ssncferreira deleted the ssncferreira/metricsdocgen-ast-scanner-newdesc branch February 13, 2026 11:01
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants