Skip to content

Commit

Permalink
refactor: increment errors counter when retries have been depleted
Browse files Browse the repository at this point in the history
Right now if an error occurs when attempting to store the payload in the
first attempt, the "processing errors" counter is incremented, even if
that payload might be properly stored in a second attempt.

This might trigger alerts that actually do not really need any
attention, since the payloads might be getting updated correctly.

RHCLOUD-36896
  • Loading branch information
MikelAlejoBR committed Dec 12, 2024
1 parent 9228899 commit d12af4d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/kafka/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/redhatinsights/payload-tracker-go/internal/queries"
)


type handler struct {
db *gorm.DB
}
Expand Down Expand Up @@ -117,13 +116,13 @@ func (this *handler) onMessage(ctx context.Context, msg *kafka.Message, cfg *con
endpoints.IncMessagesProcessed()
result := queries.InsertPayloadStatus(this.db, sanitizedPayloadStatus)
if result.Error != nil {
endpoints.IncMessageProcessErrors()
l.Log.Debug("Failed to insert sanitized PayloadStatus with ERROR: ", result.Error)
result = queries.InsertPayloadStatus(this.db, sanitizedPayloadStatus)
if result.Error != nil {
l.Log.Debug("Failed to re-insert sanitized PayloadStatus with ERROR: ", result.Error)
result = queries.InsertPayloadStatus(this.db, sanitizedPayloadStatus)
if result.Error != nil {
endpoints.IncMessageProcessErrors()
l.Log.Error("Failed final attempt to re-insert PayloadStatus with ERROR: ", result.Error)
}
}
Expand Down

0 comments on commit d12af4d

Please sign in to comment.