Class: QueuePulse::Alert
- Inherits:
-
Object
- Object
- QueuePulse::Alert
- Defined in:
- lib/queue_pulse/alert.rb
Overview
An immutable description of something worth notifying about.
fingerprint is the dedupe/cooldown key: alerts sharing a fingerprint are considered "the same ongoing condition" and are rate-limited together.
Constant Summary collapse
- SEVERITIES =
%i[info warning critical].freeze
- SEVERITY_EMOJI =
{ info: "🔵", warning: "🟠", critical: "🔴" }.freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #emoji ⇒ Object
-
#initialize(type:, severity:, title:, message:, fingerprint:, context: {}) ⇒ Alert
constructor
A new instance of Alert.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, severity:, title:, message:, fingerprint:, context: {}) ⇒ Alert
Returns a new instance of Alert.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/queue_pulse/alert.rb', line 13 def initialize(type:, severity:, title:, message:, fingerprint:, context: {}) @type = type.to_sym @severity = severity.to_sym unless SEVERITIES.include?(@severity) raise ArgumentError, "severity must be one of #{SEVERITIES.inspect}" end @title = title @message = @context = context.freeze @fingerprint = fingerprint freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def context @context end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def fingerprint @fingerprint end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def severity @severity end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/queue_pulse/alert.rb', line 11 def type @type end |
Instance Method Details
#emoji ⇒ Object
40 41 42 |
# File 'lib/queue_pulse/alert.rb', line 40 def emoji SEVERITY_EMOJI.fetch(severity, "⚪️") end |
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/queue_pulse/alert.rb', line 27 def to_h { type: type, severity: severity, title: title, message: , context: context, fingerprint: fingerprint } end |