Class: SidekiqVigil::Result
- Inherits:
-
Object
- Object
- SidekiqVigil::Result
- Defined in:
- lib/sidekiq_vigil/result.rb
Constant Summary collapse
- SEVERITIES =
%i[ok warn critical error].freeze
Instance Attribute Summary collapse
-
#check_name ⇒ Object
readonly
Returns the value of attribute check_name.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #alert_id ⇒ Object
-
#initialize(check_name:, severity:, target: "global", value: nil, threshold: nil, message: nil, metadata: {}) ⇒ Result
constructor
A new instance of Result.
- #ok? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(check_name:, severity:, target: "global", value: nil, threshold: nil, message: nil, metadata: {}) ⇒ Result
Returns a new instance of Result.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sidekiq_vigil/result.rb', line 9 def initialize(check_name:, severity:, target: "global", value: nil, threshold: nil, message: nil, metadata: {}) severity = severity.to_sym raise ArgumentError, "unknown severity: #{severity}" unless SEVERITIES.include?(severity) @check_name = check_name.to_s @target = target.to_s @severity = severity @value = value @threshold = threshold @message = @metadata = .freeze freeze end |
Instance Attribute Details
#check_name ⇒ Object (readonly)
Returns the value of attribute check_name.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def check_name @check_name end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def @message end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def @metadata end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def severity @severity end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def target @target end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def threshold @threshold end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/sidekiq_vigil/result.rb', line 7 def value @value end |
Instance Method Details
#alert_id ⇒ Object
27 28 29 |
# File 'lib/sidekiq_vigil/result.rb', line 27 def alert_id "#{check_name}:#{target}" end |
#ok? ⇒ Boolean
23 24 25 |
# File 'lib/sidekiq_vigil/result.rb', line 23 def ok? severity == :ok end |
#to_h ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sidekiq_vigil/result.rb', line 31 def to_h { check_name: check_name, target: target, severity: severity, value: value, threshold: threshold, message: , metadata: } end |