From 6210779717667326f542a4678f6cdb03df877ccd Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Thu, 11 Jan 2024 13:47:35 -0500 Subject: [PATCH] query once --- flow/shared/alerting/alerting.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flow/shared/alerting/alerting.go b/flow/shared/alerting/alerting.go index 66ea558ada..18c6cc2b9b 100644 --- a/flow/shared/alerting/alerting.go +++ b/flow/shared/alerting/alerting.go @@ -63,7 +63,8 @@ func NewAlerter(catalogPool *pgxpool.Pool) (*Alerter, error) { // Only raises an alert if another alert with the same key hasn't been raised // in the past X minutes, where X is configurable and defaults to 15 minutes func (a *Alerter) AlertIf(ctx context.Context, alertKey string, alertMessage string) { - if dynamicconf.PeerDBAlertingGapMinutesAsDuration(ctx) == 0 { + dur := dynamicconf.PeerDBAlertingGapMinutesAsDuration(ctx) + if dur == 0 { a.logger.WarnContext(ctx, "Alerting disabled via environment variable, returning") return } @@ -80,7 +81,7 @@ func (a *Alerter) AlertIf(ctx context.Context, alertKey string, alertMessage str return } - if time.Since(createdTimestamp) >= dynamicconf.PeerDBAlertingGapMinutesAsDuration(ctx) { + if time.Since(createdTimestamp) >= dur { a.AddAlertToCatalog(ctx, alertKey, alertMessage) a.AlertToSlack(ctx, alertKey, alertMessage) }