diff --git a/services/manifest-repo-export-service/pkg/cmd/server.go b/services/manifest-repo-export-service/pkg/cmd/server.go index d44b61592..0aa61283c 100755 --- a/services/manifest-repo-export-service/pkg/cmd/server.go +++ b/services/manifest-repo-export-service/pkg/cmd/server.go @@ -321,12 +321,10 @@ func processEsls(ctx context.Context, repo repository.Repository, dbHandler *db. if err2 != nil { d := sleepDuration.NextBackOff() logger.FromContext(ctx).Sugar().Warnf("error pushing, will try again in %v", d) - if ddMetrics != nil { - if err := ddMetrics.Gauge("manifest_export_push_failures", 1, []string{}, 1); err != nil { - log.Error("Error in ddMetrics.Gauge %v", err) - } - } + measurePushes(ddMetrics, log, true) time.Sleep(d) + } else { + measurePushes(ddMetrics, log, false) } return err2 }) @@ -342,6 +340,18 @@ func processEsls(ctx context.Context, repo repository.Repository, dbHandler *db. } } +func measurePushes(ddMetrics statsd.ClientInterface, log *zap.SugaredLogger, failure bool) { + if ddMetrics != nil { + var value float64 = 0 + if failure { + value = 1 + } + if err := ddMetrics.Gauge("manifest_export_push_failures", value, []string{}, 1); err != nil { + log.Error("Error in ddMetrics.Gauge %v", err) + } + } +} + func handleOneEvent(ctx context.Context, transaction *sql.Tx, dbHandler *db.DBHandler, ddMetrics statsd.ClientInterface, repo repository.Repository) (repository.Transformer, *db.EslEventRow, error) { log := logger.FromContext(ctx).Sugar() eslVersion, err := cutoff.DBReadCutoff(dbHandler, ctx, transaction)