Skip to content

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

@wenhug

Description

@wenhug

Bug

MaxPodHitCount is defined in pkg/kvcache/metrics/collector.go:44 and actively used in pkg/kvcache/kvblock/instrumented_index.go:90, but it is not included in the Collectors() slice at collector.go:78-84.

Since Register() calls metrics.Registry.MustRegister(Collectors()...), MaxPodHitCount is never registered with the Prometheus registry. This means the metric is silently dropped — no scrape error, no panic, but the data is never exposed.

Impact

  • kvcache_index_max_pod_hit_count_total is invisible to Prometheus/Grafana
  • Operators cannot monitor per-pod cache hit distribution
  • The recordHitMetrics goroutine in instrumented_index.go:71 runs on every Lookup call but its output is discarded

Root Cause

MaxPodHitCount was likely added after the initial Collectors() list was written and was not appended to the slice.

Additionally, logMetrics() does not log MaxPodHitCount, so the periodic metrics beat also omits this value.

Fix

  1. Add MaxPodHitCount to the Collectors() return slice
  2. Add MaxPodHitCount to logMetrics() output
  3. Add test coverage for MaxPodHitCount in collector_test.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions