Class: SidekiqVigil::Check::Base
- Inherits:
-
Object
- Object
- SidekiqVigil::Check::Base
- Defined in:
- lib/sidekiq_vigil/check/base.rb
Direct Known Subclasses
FailureRate, Memory, ProcessAlive, QueueLatency, QueueSize, RedisHealth, ScheduledBacklog, SetSize, StuckJobs, ThroughputAnomaly, Utilization
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #call ⇒ Object
- #check_name ⇒ Object
- #execute ⇒ Object
-
#initialize(storage:, options: {}, clock: -> { Time.now }, logger: SidekiqVigil.logger, api: SidekiqApi.new) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(storage:, options: {}, clock: -> { Time.now }, logger: SidekiqVigil.logger, api: SidekiqApi.new) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 |
# File 'lib/sidekiq_vigil/check/base.rb', line 8 def initialize(storage:, options: {}, clock: -> { Time.now }, logger: SidekiqVigil.logger, api: SidekiqApi.new) @storage = storage @options = @clock = clock @logger = logger @api = api end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/sidekiq_vigil/check/base.rb', line 6 def api @api end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
6 7 8 |
# File 'lib/sidekiq_vigil/check/base.rb', line 6 def clock @clock end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/sidekiq_vigil/check/base.rb', line 6 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/sidekiq_vigil/check/base.rb', line 6 def @options end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
6 7 8 |
# File 'lib/sidekiq_vigil/check/base.rb', line 6 def storage @storage end |
Instance Method Details
#call ⇒ Object
28 29 30 |
# File 'lib/sidekiq_vigil/check/base.rb', line 28 def call raise NotImplementedError, "#{self.class} must implement #call" end |
#check_name ⇒ Object
32 33 34 35 |
# File 'lib/sidekiq_vigil/check/base.rb', line 32 def check_name class_name = self.class.name || "custom_check" class_name.split("::").last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase end |
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sidekiq_vigil/check/base.rb', line 16 def execute Array(call) rescue StandardError => e logger.error("[sidekiq-vigil] #{check_name} failed: #{e.class}: #{e.}") [Result.new( check_name:, severity: :error, message: "#{e.class}: #{e.}", metadata: { exception_class: e.class.name } )] end |