Skip to content

Commit 6ecd006

Browse files
Merge pull request #4323 from rajagopalanand/notify-attempt-count
Fix logged notification count
2 parents 9b35e76 + 62deeb6 commit 6ecd006

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

notify/notify.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ func (r RetryStage) exec(ctx context.Context, l *slog.Logger, alerts ...*types.A
828828
}
829829

830830
for {
831-
i++
831+
832832
// Always check the context first to not notify again.
833833
select {
834834
case <-ctx.Done():
@@ -852,6 +852,7 @@ func (r RetryStage) exec(ctx context.Context, l *slog.Logger, alerts ...*types.A
852852
case <-tick.C:
853853
now := time.Now()
854854
retry, err := r.integration.Notify(ctx, sent...)
855+
i++
855856
dur := time.Since(now)
856857
r.metrics.notificationLatencySeconds.WithLabelValues(r.labelValues...).Observe(dur.Seconds())
857858
r.metrics.numNotificationRequestsTotal.WithLabelValues(r.labelValues...).Inc()

notify/notify_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ func TestRetryStageWithContextCanceled(t *testing.T) {
499499
counter := r.metrics.numTotalFailedNotifications
500500

501501
require.Equal(t, 1, int(prom_testutil.ToFloat64(counter.WithLabelValues(r.integration.Name(), ContextCanceledReason.String()))))
502+
require.Contains(t, err.Error(), "notify retry canceled after 1 attempts: context canceled")
502503

503504
require.Error(t, err)
504505
require.NotNil(t, resctx)

0 commit comments

Comments
 (0)