feat(scripts/metricsdocgen): support merging static and generated metrics files - #21464
Conversation
290834d to
c5a36c6
Compare
403a3c5 to
65a7c50
Compare
c5a36c6 to
0a2e6a5
Compare
65a7c50 to
c64eacf
Compare
0a2e6a5 to
0b325ff
Compare
c64eacf to
debcf77
Compare
3ee81f5 to
d39d62e
Compare
debcf77 to
dac0195
Compare
d39d62e to
316234e
Compare
b53a4eb to
556e481
Compare
07b917e to
b43e7ff
Compare
556e481 to
7f37f96
Compare
b43e7ff to
fbec171
Compare
519ac0a to
f251035
Compare
fbec171 to
ad22659
Compare
f251035 to
da49da0
Compare
d5993fc to
669ef40
Compare
1fba71b to
b5fdd68
Compare
23d403e to
10d83e9
Compare
16db381 to
f4acd97
Compare
10d83e9 to
0c10e4e
Compare
Documentation CheckThis PR refactors the metrics documentation generator to support merging static and generated metrics files. The following documentation updates are needed: New Documentation Needed
ContextThe tool now reads from two files:
Without documentation, developers won't know:
Automated review via Coder Tasks |
f4acd97 to
7e10dcf
Compare
d9d6977 to
ca4d6a7
Compare
7e10dcf to
65028be
Compare
Documentation CheckThis PR refactors the metrics documentation generator to support merging static and generated metrics files. The documentation needs identified in the previous review are being addressed in the upstack PR. Updates Deferred to Upstack PR #21465
Recent Updates in This PR
Optional Enhancement
This is optional since the code includes clear inline comments explaining the feature. No Action RequiredThe PR correctly defers Makefile integration and developer documentation to upstack PR #21465. The core refactoring is complete, and the Automated review via Coder Tasks |
eb7475b to
ef089f3
Compare
b35a400 to
c7d424c
Compare
Merge activity
|
7211224 to
7fdcd5a
Compare

Description
This PR refactors
scripts/metricsdocgen/main.goto support merging static and generated metrics files for documentation generation.The static
metricsfile remains necessary for metrics not defined in the coder codebase (go_*,process_*,promhttp_*,coder_aibridged_*), as well as edge cases the scanner cannot handle (e.g., such as metrics with runtime-determined labels or function-local variable references for fields, ...). Handling these edge cases in the scanner would make it significantly more complex, so we keep this hybrid approach to accommodate them. This means that in such cases, developers need to update themetricsfile directly, meaning there is still a risk of out-of-date information in the documentation. However, this solution should already encompass most cases.Static metrics take priority over generated metrics when both files contain the same metric name, allowing manual overrides without modifying the scanner. Some of these edge cases could be easily fixed by updating the codebase to use one of the supported patterns.
Changes
scripts/metricsdocgen/main.goto read from two separate metrics files:metrics: static, manually maintained metrics (e.g.,go_*,process_*,promhttp_*,coder_aibridged_*)generated_metrics: auto-generated by the AST scannermetricsfile to contain only static and edge-case metricsgenerated_metricsto reflect skipped metricsdocs/admin/integrations/prometheus.mdwith merged metricsRelated to: #13223
Disclosure: This PR was mainly developed with Claude Sonnet 4, with iterative review and refinement by @ssncferreira