Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add the ability for problem checks to specify 'max blips' (#26388)

Ted Johansson5875b25e6802
diff --git a/app/models/problem_check.rb b/app/models/problem_check.rb
index 82e8cd124bb..bafa2a1eff9 100644
--- a/app/models/problem_check.rb
+++ b/app/models/problem_check.rb
@@ -21,6 +21,13 @@ class ProblemCheck
#
config_accessor :retry_after, default: 30.seconds, instance_writer: false
+ # How many consecutive times the check can fail without notifying admins.
+ # This can be used to give some leeway for transient problems. Note that
+ # retries are not counted. So a check that ultimately fails after e.g. two
+ # retries is counted as one "blip".
+ #
+ config_accessor :max_blips, default: 0, instance_writer: false
+
def self.[](key)
key = key.to_sym
diff --git a/app/models/problem_check_tracker.rb b/app/models/problem_check_tracker.rb
index a8f19b1bb5c..5899cb57df8 100644
--- a/app/models/problem_check_tracker.rb
+++ b/app/models/problem_check_tracker.rb
@@ -27,6 +27,12 @@ class ProblemCheckTracker < ActiveRecord::Base
def check
ProblemCheck[identifier]
end
+
+ private
+
+ def sound_the_alarm?
+ blips > check.max_blips
+ end
end
# == Schema Information