Skip to content

Commit

Permalink
fix(metrics): convert duration to seconds for histogram value
Browse files Browse the repository at this point in the history
Otherwise, this passes in the raw nano/micro/whatever seconds value, and
for quick/noop type scripts, execution times can be extremely short,
causing the histogrm to otherwise register this only under the
`Infinity` bucket, since the value was technically higher than the max
bucket
  • Loading branch information
tjhop committed Aug 9, 2024
1 parent 1faab44 commit b0c2dec
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions internal/manager/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ 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
metricManagerModuleRunDuration.With(labels).Observe(float64(time.Since(testStart).Seconds()))
metricManagerModuleRunTotal.With(labels).Inc()
switch {
case err != nil:
Expand All @@ -170,9 +171,6 @@ func (mgr *Manager) RunModule(ctx context.Context, logger *slog.Logger, mod Modu
default:
metricManagerModuleRunSuccessTimestamp.With(labels).Set(float64(testStart.Unix()))
}

testEnd := time.Since(testStart)
metricManagerModuleRunDuration.With(labels).Observe(float64(testEnd))
}

if viper.GetBool("manager.skip-apply-on-test-success") && mod.m.Test != "" && testRC == 0 {
Expand Down

0 comments on commit b0c2dec

Please sign in to comment.