Skip to content

Commit

Permalink
vtorc/logic: use gauge for detected problems
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Abushareb <[email protected]>
  • Loading branch information
yields committed Sep 21, 2023
1 parent 7371434 commit 155a803
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions go/vt/vtorc/logic/topology_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 155a803

Please sign in to comment.