Class: SidekiqMonitoring::Queue
- Inherits:
-
Object
- Object
- SidekiqMonitoring::Queue
- Includes:
- StatusMixin
- Defined in:
- lib/sidekiq-monitoring.rb
Constant Summary collapse
- DEFAULT_THRESHOLD =
[ 1_000, 2_000 ]
- DEFAULT_LATENCY_THRESHOLD =
[ 300, 900 ]
Instance Attribute Summary collapse
-
#latency ⇒ Object
Returns the value of attribute latency.
-
#latency_critical_threshold ⇒ Object
Returns the value of attribute latency_critical_threshold.
-
#latency_warning_threshold ⇒ Object
Returns the value of attribute latency_warning_threshold.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#queue_size_critical_threshold ⇒ Object
Returns the value of attribute queue_size_critical_threshold.
-
#queue_size_warning_threshold ⇒ Object
Returns the value of attribute queue_size_warning_threshold.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes included from StatusMixin
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(name, size, latency, queue_size_thresholds = nil, latency_thresholds = nil) ⇒ Queue
constructor
A new instance of Queue.
- #monitoring_status ⇒ Object
Methods included from StatusMixin
Constructor Details
#initialize(name, size, latency, queue_size_thresholds = nil, latency_thresholds = nil) ⇒ Queue
Returns a new instance of Queue.
107 108 109 110 111 112 113 114 |
# File 'lib/sidekiq-monitoring.rb', line 107 def initialize(name, size, latency, queue_size_thresholds = nil, latency_thresholds = nil) @name = name @size = size @latency = latency @queue_size_warning_threshold, @queue_size_critical_threshold = (queue_size_thresholds ? queue_size_thresholds : DEFAULT_THRESHOLD) @latency_warning_threshold, @latency_critical_threshold = (latency_thresholds ? latency_thresholds : DEFAULT_LATENCY_THRESHOLD) @status = monitoring_status end |
Instance Attribute Details
#latency ⇒ Object
Returns the value of attribute latency.
105 106 107 |
# File 'lib/sidekiq-monitoring.rb', line 105 def latency @latency end |
#latency_critical_threshold ⇒ Object
Returns the value of attribute latency_critical_threshold.
105 106 107 |
# File 'lib/sidekiq-monitoring.rb', line 105 def latency_critical_threshold @latency_critical_threshold end |
#latency_warning_threshold ⇒ Object
Returns the value of attribute latency_warning_threshold.
105 106 107 |
# File 'lib/sidekiq-monitoring.rb', line 105 def latency_warning_threshold @latency_warning_threshold end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
104 105 106 |
# File 'lib/sidekiq-monitoring.rb', line 104 def name @name end |
#queue_size_critical_threshold ⇒ Object
Returns the value of attribute queue_size_critical_threshold.
105 106 107 |
# File 'lib/sidekiq-monitoring.rb', line 105 def queue_size_critical_threshold @queue_size_critical_threshold end |
#queue_size_warning_threshold ⇒ Object
Returns the value of attribute queue_size_warning_threshold.
105 106 107 |
# File 'lib/sidekiq-monitoring.rb', line 105 def queue_size_warning_threshold @queue_size_warning_threshold end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
104 105 106 |
# File 'lib/sidekiq-monitoring.rb', line 104 def size @size end |
Instance Method Details
#as_json ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/sidekiq-monitoring.rb', line 116 def as_json { 'name' => name, 'status' => status, 'size' => size, 'queue_size_warning_threshold' => queue_size_warning_threshold, 'queue_size_critical_threshold' => queue_size_critical_threshold, 'latency' => latency, 'latency_warning_threshold' => latency_warning_threshold, 'latency_critical_threshold' => latency_critical_threshold } end |
#monitoring_status ⇒ Object
129 130 131 132 133 |
# File 'lib/sidekiq-monitoring.rb', line 129 def monitoring_status return 'CRITICAL' if size >= queue_size_critical_threshold || latency >= latency_critical_threshold return 'WARNING' if size >= queue_size_warning_threshold || latency >= latency_warning_threshold 'OK' end |