feat(scripts/metricsdocgen): add AST scanner core for metrics doc generation - #21460
Conversation
53b26d8 to
95bcc37
Compare
b487f0c to
aee2d85
Compare
mtojek
left a comment
There was a problem hiding this comment.
Nothing blocking, looking forward to next PR :)
| var scanDirs = []string{ | ||
| "agent", | ||
| "coderd", | ||
| "enterprise", | ||
| "provisionerd", | ||
| } |
There was a problem hiding this comment.
nit: alternative approach .metricsignore file :)
There was a problem hiding this comment.
This might be a good idea for the future, we can revisit this if needed 👍
| } | ||
|
|
||
| // scanFile parses a single Go file and extracts all Prometheus metric definitions. | ||
| func scanFile(path string) ([]Metric, error) { |
There was a problem hiding this comment.
Future: We could add some smoke tests to prevent accidental AST logic changes.
There was a problem hiding this comment.
Yes, this is missing testing. This is something we need to address in the future 👍
aee2d85 to
b8b4331
Compare
b8b4331 to
c6638df
Compare
c6638df to
a370b3f
Compare
Documentation CheckNo Changes NeededThis PR adds foundational scanner infrastructure with placeholder implementations. The actual metric extraction logic ( No documentation changes are required because:
Automated review via Coder Tasks |
0f1be8c to
1bdb883
Compare
1bdb883 to
f7f0213
Compare
Merge activity
|

Description
This PR adds an AST-based scanner to automatically generate Prometheus metrics documentation from the coder source code.
Changes
scripts/metricsdocgen/scanner/scanner.gowith:agent/,coderd/,enterprise/,provisionerd/*_test.gofiles)Metric.String()for Prometheus text exposition format renderingwriteMetrics()to output metrics to stdoutextractMetricFromCall()(implemented in subsequent PRs)scripts/metricsdocgen/generated_metricsplaceholder (populated by subsequent PRs)Note: To facilitate the review process, this was separated into scoped stacked PRs. The division was based on the main structure, the different Prometheus patterns currently present in the codebase, and updates to the build process.
Related to: #13223
Disclosure: This PR was mainly developed with Claude Sonnet 4, with iterative review and refinement by @ssncferreira