Class: Checkups::Performance
- Defined in:
- lib/checkups/performance.rb
Instance Attribute Summary collapse
-
#error_limit ⇒ Object
readonly
Returns the value of attribute error_limit.
-
#warning_limit ⇒ Object
readonly
Returns the value of attribute warning_limit.
Attributes inherited from Checkup
#name, #status, #status_message, #url, #verbose
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #check_elapsed(elapsed) ⇒ Object
-
#initialize(verbose: false, name: nil, warning_limit: 1800, error_limit: 3600) ⇒ Performance
constructor
A new instance of Performance.
Methods inherited from Checkup
#check_and_notify!, checkups_by_frequency, daily, hourly, #notify_message, #passed?
Constructor Details
#initialize(verbose: false, name: nil, warning_limit: 1800, error_limit: 3600) ⇒ Performance
11 12 13 14 15 16 17 |
# File 'lib/checkups/performance.rb', line 11 def initialize(verbose: false, name: nil, warning_limit: 1800, error_limit: 3600) super(verbose: verbose) @name = name @warning_limit = warning_limit @error_limit = error_limit ok end |
Instance Attribute Details
#error_limit ⇒ Object (readonly)
Returns the value of attribute error_limit.
9 10 11 |
# File 'lib/checkups/performance.rb', line 9 def error_limit @error_limit end |
#warning_limit ⇒ Object (readonly)
Returns the value of attribute warning_limit.
9 10 11 |
# File 'lib/checkups/performance.rb', line 9 def warning_limit @warning_limit end |
Class Method Details
.frequency ⇒ Object
5 6 7 |
# File 'lib/checkups/performance.rb', line 5 def self.frequency :never end |
Instance Method Details
#check ⇒ Object
19 20 21 22 23 |
# File 'lib/checkups/performance.rb', line 19 def check start_time = Time.now.to_i yield check_elapsed(Time.now.to_i - start_time) end |
#check_elapsed(elapsed) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/checkups/performance.rb', line 25 def check_elapsed(elapsed) if warning_limit <= elapsed && elapsed < error_limit warning "#{name} took longer than #{warning_limit}s: #{elapsed}s" elsif error_limit <= elapsed error "#{name} took longer than #{error_limit}s: #{elapsed}s" else ok end end |