chore(health): log out duration of tries in milliseconds

This commit is contained in:
Quentin McGaw
2025-11-20 15:08:41 +00:00
parent 9e5624d32b
commit a445ba072c

View File

@@ -238,7 +238,7 @@ func withRetries(ctx context.Context, tryTimeouts []time.Duration,
maxTries := len(tryTimeouts) maxTries := len(tryTimeouts)
type errData struct { type errData struct {
err error err error
duration time.Duration durationMS int64
} }
errs := make([]errData, maxTries) errs := make([]errData, maxTries)
for i, timeout := range tryTimeouts { for i, timeout := range tryTimeouts {
@@ -254,12 +254,12 @@ func withRetries(ctx context.Context, tryTimeouts []time.Duration,
} }
logger.Debugf("%s attempt %d/%d failed: %s", checkName, i+1, maxTries, err) logger.Debugf("%s attempt %d/%d failed: %s", checkName, i+1, maxTries, err)
errs[i].err = err errs[i].err = err
errs[i].duration = time.Since(start) errs[i].durationMS = time.Since(start).Round(time.Millisecond).Milliseconds()
} }
errStrings := make([]string, len(errs)) errStrings := make([]string, len(errs))
for i, err := range errs { for i, err := range errs {
errStrings[i] = fmt.Sprintf("attempt %d (%s): %s", i+1, err.duration, err.err) errStrings[i] = fmt.Sprintf("attempt %d (%dms): %s", i+1, err.durationMS, err.err)
} }
return fmt.Errorf("%w: %s", ErrAllCheckTriesFailed, strings.Join(errStrings, ", ")) return fmt.Errorf("%w: %s", ErrAllCheckTriesFailed, strings.Join(errStrings, ", "))
} }