Skip to content

Commit

Permalink
Merge pull request #31 from ipni/fix-error-count
Browse files Browse the repository at this point in the history
Decrement before increment error count when changing error type
  • Loading branch information
gammazero authored Sep 25, 2023
2 parents 55b240e + 9bdb026 commit c206a2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,22 @@ func (tel *Telemetry) run(ctx context.Context, updates <-chan dtrack.DistanceUpd
for update := range updates {
if update.Err != nil {
log.Infow("Error getting distance", "provider", update.ID, "err", update.Err)
if _, ok := errored[update.ID]; !ok {
tel.metrics.NotifyProviderErrored(ctx, update.Err)
if prevErr, ok := errored[update.ID]; ok {
if prevErr.Error() != update.Err.Error() {
tel.metrics.NotifyProviderErrorCleared(ctx, prevErr)
errored[update.ID] = update.Err
tel.metrics.NotifyProviderErrored(ctx, update.Err)
log.Infow("Provider error updated", "provider", update.ID, "totalErroring", len(errored))
}
} else {
errored[update.ID] = update.Err
tel.metrics.NotifyProviderErrored(ctx, update.Err)
log.Infow("Provider marked as erroring", "provider", update.ID, "totalErroring", len(errored))
_, ok := rateMap[update.ID]
if ok {
delete(rateMap, update.ID)
tel.updateIngestRates(rateMap)
}
}
prevLen := len(rateMap)
delete(rateMap, update.ID)
if len(rateMap) != prevLen {
tel.updateIngestRates(rateMap)
}
distSum = tel.removeProviderFromDistBucket(ctx, update.ID, distSum)
} else {
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.0.3"
"version": "v0.0.4"
}

0 comments on commit c206a2b

Please sign in to comment.