fix: register MaxPodHitCount metric in Collectors()#509
Open
wenhug wants to merge 2 commits intollm-d:mainfrom
Open
fix: register MaxPodHitCount metric in Collectors()#509wenhug wants to merge 2 commits intollm-d:mainfrom
wenhug wants to merge 2 commits intollm-d:mainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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
MaxPodHitCounttoCollectors()soRegister()includes it inMustRegister(...). - Include
max_pod_hit_countin the periodiclogMetrics()output. - Add tests to ensure
Collectors()includes all expected collectors and thatlogMetrics()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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MaxPodHitCountto theCollectors()return slice so it is registered with the Prometheus registryMaxPodHitCountto the periodiclogMetrics()outputTestCollectorsIncludesAllMetricsto verify all defined metrics are included inCollectors()max_pod_hit_count_loggedsubtest to verifylogMetrics()outputs the new fieldProblem
MaxPodHitCountis defined incollector.go:44and actively used ininstrumented_index.go:90viarecordHitMetrics(), but it was not included in theCollectors()slice. SinceRegister()callsmetrics.Registry.MustRegister(Collectors()...), the metric was never registered — makingkvcache_index_max_pod_hit_count_totalinvisible to Prometheus/Grafana.Test plan
TestCollectorsIncludesAllMetrics— verifies every defined metric is inCollectors()TestLogMetrics/max_pod_hit_count_logged— verifieslogMetrics()includes the fieldgo test ./pkg/kvcache/metrics/ -vFixes #508