Skip to content

Commit

Permalink
query once
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Jan 11, 2024
1 parent f942619 commit 6210779
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions flow/shared/alerting/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 6210779

Please sign in to comment.