Skip to content

Fix logged notification count #4323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ func (r RetryStage) exec(ctx context.Context, l *slog.Logger, alerts ...*types.A
}

for {
i++

// Always check the context first to not notify again.
select {
case <-ctx.Done():
Expand All @@ -852,6 +852,7 @@ func (r RetryStage) exec(ctx context.Context, l *slog.Logger, alerts ...*types.A
case <-tick.C:
now := time.Now()
retry, err := r.integration.Notify(ctx, sent...)
i++
dur := time.Since(now)
r.metrics.notificationLatencySeconds.WithLabelValues(r.labelValues...).Observe(dur.Seconds())
r.metrics.numNotificationRequestsTotal.WithLabelValues(r.labelValues...).Inc()
Expand Down
1 change: 1 addition & 0 deletions notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ func TestRetryStageWithContextCanceled(t *testing.T) {
counter := r.metrics.numTotalFailedNotifications

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

require.Error(t, err)
require.NotNil(t, resctx)
Expand Down