From 155a803a8ba585f9d9858692a0c1a84d80904f37 Mon Sep 17 00:00:00 2001 From: Amir Abushareb Date: Thu, 21 Sep 2023 08:45:23 +0100 Subject: [PATCH] vtorc/logic: use gauge for detected problems Signed-off-by: Amir Abushareb --- go/vt/vtorc/logic/topology_recovery.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/go/vt/vtorc/logic/topology_recovery.go b/go/vt/vtorc/logic/topology_recovery.go index 89eb555dbb5..d6b6b4b1bae 100644 --- a/go/vt/vtorc/logic/topology_recovery.go +++ b/go/vt/vtorc/logic/topology_recovery.go @@ -63,8 +63,11 @@ var ( countPendingRecoveries = stats.NewGauge("PendingRecoveries", "Count of the number of pending recoveries") - // detectedProblemsCounter is used to count the number of detected problems. - detectedProblemsCounter = stats.NewCountersWithMultiLabels("DetectedProblems", "Count of the different detected problems", []string{ + // detectedProblems is used to track the number of detected problems. + // + // When an issue is active it will be set to 1, when it is no longer active + // it will be reset back to 0. + detectedProblems = stats.NewGaugesWithMultiLabels("DetectedProblems", "Count of the different detected problems", []string{ "Analysis", "TabletAlias", "Keyspace", @@ -777,17 +780,16 @@ func CheckAndRecover() { e.AnalyzedShard, } - key := detectedProblemsCounter.GetLabelName(names[:]...) + key := detectedProblems.GetLabelName(names[:]...) active[key] = names[:] - detectedProblemsCounter.Reset(names[:]) - detectedProblemsCounter.Add(names[:], 1) + detectedProblems.Set(names[:], 1) } } // Reset any non-active problems. - for key := range detectedProblemsCounter.Counts() { + for key := range detectedProblems.Counts() { if names, ok := active[key]; !ok { - detectedProblemsCounter.Reset(names) + detectedProblems.Set(names, 0) } }