Skip to content

Commit

Permalink
fix: measure push failures also in success case (#1845)
Browse files Browse the repository at this point in the history
So that we always send data to datadog.

Ref: SRX-4CJW8O
  • Loading branch information
sven-urbanski-freiheit-com authored Aug 7, 2024
1 parent 3c39201 commit bac1618
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions services/manifest-repo-export-service/pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand All @@ -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)
Expand Down

0 comments on commit bac1618

Please sign in to comment.