Skip to content

fix: register MaxPodHitCount metric in Collectors()#509

Open
wenhug wants to merge 2 commits intollm-d:mainfrom
wenhug:fix/register-max-pod-hit-count-metric
Open

fix: register MaxPodHitCount metric in Collectors()#509
wenhug wants to merge 2 commits intollm-d:mainfrom
wenhug:fix/register-max-pod-hit-count-metric

Conversation

@wenhug
Copy link
Copy Markdown
Contributor

@wenhug wenhug commented Apr 10, 2026

Summary

  • Add MaxPodHitCount to the Collectors() return slice so it is registered with the Prometheus registry
  • Add MaxPodHitCount to the periodic logMetrics() output
  • Add TestCollectorsIncludesAllMetrics to verify all defined metrics are included in Collectors()
  • Add max_pod_hit_count_logged subtest to verify logMetrics() outputs the new field

Problem

MaxPodHitCount is defined in collector.go:44 and actively used in instrumented_index.go:90 via recordHitMetrics(), but it was not included in the Collectors() slice. Since Register() calls metrics.Registry.MustRegister(Collectors()...), the metric was never registered — making kvcache_index_max_pod_hit_count_total invisible to Prometheus/Grafana.

Test plan

  • TestCollectorsIncludesAllMetrics — verifies every defined metric is in Collectors()
  • TestLogMetrics/max_pod_hit_count_logged — verifies logMetrics() includes the field
  • All existing tests pass: go test ./pkg/kvcache/metrics/ -v

Fixes #508

MaxPodHitCount is defined and used in instrumented_index.go but was
not included in the Collectors() slice, so it was never registered
with the Prometheus registry. This made the metric invisible to
scraping.

Also add MaxPodHitCount to the periodic logMetrics() output and
add test coverage to prevent future regressions.

Fixes llm-d#508

Signed-off-by: Wenhan Guo <whguo@ucsd.edu>
Signed-off-by: wenhug <50309350+wenhug@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 06:03
@github-actions github-actions bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Registers the previously-defined MaxPodHitCount Prometheus metric so it becomes visible to the registry/scrapes, and extends periodic metrics logging and tests to cover it.

Changes:

  • Add MaxPodHitCount to Collectors() so Register() includes it in MustRegister(...).
  • Include max_pod_hit_count in the periodic logMetrics() output.
  • Add tests to ensure Collectors() includes all expected collectors and that logMetrics() emits the new field.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/kvcache/metrics/collector.go Registers MaxPodHitCount via Collectors() and logs it in logMetrics().
pkg/kvcache/metrics/collector_test.go Adds coverage for Collectors() completeness and validates logMetrics() includes max_pod_hit_count.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Detect duplicate collectors in TestCollectorsIncludesAllMetrics to
  guard against MustRegister panics at runtime
- Assert exact metric value (max_pod_hit_count=42) instead of only
  checking field presence

Signed-off-by: Wenhan Guo <whguo@ucsd.edu>
Signed-off-by: wenhug <50309350+wenhug@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: MaxPodHitCount metric not registered in Collectors(), invisible to Prometheus

2 participants