Skip to content

Commit

Permalink
fix(metrics): always increment module run metric for test runs
Browse files Browse the repository at this point in the history
If a test script exists and we're asked to run it, always increment the
total module runs for the script, regardless of whether it errors or
fails -- we were still asked to run it and the count should reflect
that.
  • Loading branch information
tjhop committed Aug 9, 2024
1 parent e32ac9f commit 1faab44
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/manager/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func (mgr *Manager) RunModule(ctx context.Context, logger *slog.Logger, mod Modu
}

testRC, err = shell.Run(ctx, runID, mod.m.Test, renderedTest, allVars)
// update metrics regardless of error, so do them before handling error
metricManagerModuleRunTotal.With(labels).Inc()
switch {
case err != nil:
// if test script for a module fails, log a warning for user and continue with apply
Expand All @@ -166,7 +168,6 @@ func (mgr *Manager) RunModule(ctx context.Context, logger *slog.Logger, mod Modu
slog.Any("exit_code", testRC),
)
default:
metricManagerModuleRunTotal.With(labels).Inc()
metricManagerModuleRunSuccessTimestamp.With(labels).Set(float64(testStart.Unix()))
}

Expand Down

0 comments on commit 1faab44

Please sign in to comment.