Skip to content

Commit

Permalink
reconciler: Fix the prune total errors expvar
Browse files Browse the repository at this point in the history
The example expvar metrics implementation incremented the
total errors variable even when there wasn't an error.

Signed-off-by: Jussi Maki <jussi.maki@isovalent.com>
  • Loading branch information
joamaki committed Sep 6, 2024
1 parent 2be89fe commit 574b83f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions reconciler/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func registerHTTPServer(

mux := http.NewServeMux()

// To dump the metrics:
// curl -s http://localhost:8080/expvar
mux.Handle("/expvar", expvar.Handler())

// For dumping the database:
Expand Down
2 changes: 1 addition & 1 deletion reconciler/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func (m *ExpVarMetrics) PruneDuration(moduleID cell.FullModuleID, duration time.

func (m *ExpVarMetrics) PruneError(moduleID cell.FullModuleID, err error) {
m.PruneCountVar.Add(moduleID.String(), 1)
m.PruneTotalErrorsVar.Add(moduleID.String(), 1)

var intVar expvar.Int
if err != nil {
m.PruneTotalErrorsVar.Add(moduleID.String(), 1)
intVar.Set(1)
}
m.PruneCurrentErrorsVar.Set(moduleID.String(), &intVar)
Expand Down

0 comments on commit 574b83f

Please sign in to comment.