Skip to content

docs: support opmetrics/pmetrics metric constructors in metrics doc generator#9119

Open
DerekFrank wants to merge 1 commit intoaws:mainfrom
DerekFrank:upstream-metrics-gen-fix
Open

docs: support opmetrics/pmetrics metric constructors in metrics doc generator#9119
DerekFrank wants to merge 1 commit intoaws:mainfrom
DerekFrank:upstream-metrics-gen-fix

Conversation

@DerekFrank
Copy link
Copy Markdown
Contributor

@DerekFrank DerekFrank commented Apr 28, 2026

Fixes #N/A

Description

The metrics documentation generator only recognized prometheus.New*() calls for extracting metric declarations from source code. After the migration to operatorpkg's opmetrics.NewPrometheus*() and pmetrics.NewPrometheus*() wrappers, the generator silently dropped all karpenter core and provider-aws metrics, producing incomplete documentation.

Changes:

  • Use ast.Inspect to walk entire AST including function bodies, replacing the previous top-level-var-only scan. This picks up metrics initialized inside functions (e.g. node controller's initializeMetrics(), operatorpkg's RegisterClientMetrics()).
  • Recognize opmetrics, pmetrics, and unqualified NewPrometheus* calls with the correct opts argument index (Args[1] instead of Args[0]).
  • Skip unresolvable identifiers gracefully instead of fataling, since ast.Inspect encounters local variables in helper function bodies.
  • Filter out _test.go files from parsing to avoid picking up test metrics.
  • Add perObjectStatusMetrics() to generate the per-object status condition and termination metrics that are dynamically created at runtime by operatorpkg's status.NewControllerT.
  • Add pmetrics.Namespace to the identifier mapping.
  • Add per-object subsystem sort ordering and stability level entries.

How was this change tested?

Updated the docs as evidence of success

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@DerekFrank DerekFrank requested a review from a team as a code owner April 28, 2026 19:07
@DerekFrank DerekFrank requested a review from ellistarn April 28, 2026 19:07
@DerekFrank DerekFrank force-pushed the upstream-metrics-gen-fix branch from 2ababfc to 0378d87 Compare April 28, 2026 19:08
@DerekFrank DerekFrank changed the title fix: support opmetrics/pmetrics metric constructors in metrics doc generator docs: support opmetrics/pmetrics metric constructors in metrics doc generator Apr 28, 2026
@DerekFrank DerekFrank force-pushed the upstream-metrics-gen-fix branch from 0378d87 to e5aa148 Compare April 28, 2026 20:26
@DerekFrank DerekFrank marked this pull request as draft April 28, 2026 21:30
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Preview deployment ready!

Preview URL: https://pr-9119.d18coufmbnnaag.amplifyapp.com

Built from commit 37343ac4adc56d80c1c27f777696b55bc0ffdb4f

@DerekFrank DerekFrank force-pushed the upstream-metrics-gen-fix branch 4 times, most recently from 2df8925 to 0d3f52e Compare April 30, 2026 00:03
…ctors and regenerate all versioned metrics docs
@DerekFrank DerekFrank force-pushed the upstream-metrics-gen-fix branch from 0d3f52e to 37343ac Compare May 8, 2026 21:50
@DerekFrank DerekFrank marked this pull request as ready for review May 8, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant