Class: Gitlab::Memory::ReportsDaemon
- Defined in:
- lib/gitlab/memory/reports_daemon.rb
Constant Summary collapse
- DEFAULT_SLEEP_S =
2 hours
7200
- DEFAULT_SLEEP_MAX_DELTA_S =
0..10 minutes
600
- DEFAULT_SLEEP_BETWEEN_REPORTS_S =
2 minutes
120
Instance Attribute Summary collapse
-
#sleep_between_reports_s ⇒ Object
readonly
Returns the value of attribute sleep_between_reports_s.
-
#sleep_max_delta_s ⇒ Object
readonly
Returns the value of attribute sleep_max_delta_s.
-
#sleep_s ⇒ Object
readonly
Returns the value of attribute sleep_s.
Attributes inherited from Daemon
Instance Method Summary collapse
-
#initialize(reporter: nil, reports: nil, **options) ⇒ ReportsDaemon
constructor
A new instance of ReportsDaemon.
- #run_thread ⇒ Object
Methods inherited from Daemon
#enabled?, initialize_instance, instance, #start, #stop, #thread?, #thread_name
Constructor Details
#initialize(reporter: nil, reports: nil, **options) ⇒ ReportsDaemon
Returns a new instance of ReportsDaemon.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gitlab/memory/reports_daemon.rb', line 10 def initialize(reporter: nil, reports: nil, **) super @alive = true @sleep_s = ENV['GITLAB_DIAGNOSTIC_REPORTS_SLEEP_S']&.to_i || DEFAULT_SLEEP_S @sleep_max_delta_s = ENV['GITLAB_DIAGNOSTIC_REPORTS_SLEEP_MAX_DELTA_S']&.to_i || DEFAULT_SLEEP_MAX_DELTA_S @sleep_between_reports_s = ENV['GITLAB_DIAGNOSTIC_REPORTS_SLEEP_BETWEEN_REPORTS_S']&.to_i || DEFAULT_SLEEP_BETWEEN_REPORTS_S @reporter = reporter || Reporter.new @reports = reports || [ Gitlab::Memory::Reports::JemallocStats.new ] end |
Instance Attribute Details
#sleep_between_reports_s ⇒ Object (readonly)
Returns the value of attribute sleep_between_reports_s.
28 29 30 |
# File 'lib/gitlab/memory/reports_daemon.rb', line 28 def sleep_between_reports_s @sleep_between_reports_s end |
#sleep_max_delta_s ⇒ Object (readonly)
Returns the value of attribute sleep_max_delta_s.
28 29 30 |
# File 'lib/gitlab/memory/reports_daemon.rb', line 28 def sleep_max_delta_s @sleep_max_delta_s end |
#sleep_s ⇒ Object (readonly)
Returns the value of attribute sleep_s.
28 29 30 |
# File 'lib/gitlab/memory/reports_daemon.rb', line 28 def sleep_s @sleep_s end |
Instance Method Details
#run_thread ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/memory/reports_daemon.rb', line 30 def run_thread while alive sleep interval_with_jitter reports.select(&:active?).each do |report| @reporter.run_report(report) sleep sleep_between_reports_s end end end |