Skip to content

fix(metrics): reset gauge vectors on recalculation to clear stale metrics - #1586

Draft
Neha-Nimsatkar wants to merge 1 commit into
flatcar:mainfrom
Neha-Nimsatkar:fix/metrics-reset-stale-gauge-vectors
Draft

fix(metrics): reset gauge vectors on recalculation to clear stale metrics#1586
Neha-Nimsatkar wants to merge 1 commit into
flatcar:mainfrom
Neha-Nimsatkar:fix/metrics-reset-stale-gauge-vectors

Conversation

@Neha-Nimsatkar

Copy link
Copy Markdown

fix(metrics): reset gauge vectors on recalculation to clear stale metrics

In backend/pkg/metrics/metrics.go, appInstancePerChannelGaugeMetric and failedUpdatesGaugeMetric are updated via WithLabelValues(...).Set(...) whenever calculateMetrics() executes.

When an instance upgrades, gets deregistered, or an application/version combination is no longer returned by the database queries (GetAppInstancesPerChannelMetrics or GetFailedUpdatesMetrics), the Prometheus collector retains the previous label values indefinitely in memory.

This PR adds .Reset() calls on both GaugeVec collectors before setting fresh values so that stale time-series label combinations are properly cleared on each recalculation cycle.

How to use

Reviewers can inspect calculateMetrics() in backend/pkg/metrics/metrics.go to verify that appInstancePerChannelGaugeMetric.Reset() and failedUpdatesGaugeMetric.Reset() are invoked prior to metric iteration.

Testing done

  • Ran go fmt ./pkg/metrics/... to ensure standard Go formatting.
  • Verified compilation and static analysis using:
cd backend
go build ./pkg/metrics/...

…rics

Signed-off-by: Neha-Nimsatkar <1492neha@gmail.com>
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