Module: InstJobsStatsd::Stats::Periodic::Run
- Defined in:
- lib/inst_jobs_statsd/stats/periodic/run.rb
Class Method Summary collapse
- .enable ⇒ Object
- .enable_run_age ⇒ Object
- .enable_run_depth ⇒ Object
- .report_run_age ⇒ Object
- .report_run_depth ⇒ Object
- .running_jobs_scope ⇒ Object
Class Method Details
.enable ⇒ Object
7 8 9 10 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 7 def self.enable enable_run_depth enable_run_age end |
.enable_run_age ⇒ Object
17 18 19 20 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 17 def self.enable_run_age Periodic.enable_callbacks Periodic.add(-> { report_run_age }) end |
.enable_run_depth ⇒ Object
12 13 14 15 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 12 def self.enable_run_depth Periodic.enable_callbacks Periodic.add(-> { report_run_depth }) end |
.report_run_age ⇒ Object
27 28 29 30 31 32 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 27 def self.report_run_age jobs_run_at = running_jobs_scope.limit(10_000).pluck(:run_at) age_secs = jobs_run_at.map { |t| Delayed::Job.db_time_now - t } Periodic.report_gauge(:run_age_total, age_secs.sum) Periodic.report_gauge(:run_age_max, age_secs.max || 0) end |
.report_run_depth ⇒ Object
22 23 24 25 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 22 def self.report_run_depth scope = running_jobs_scope Periodic.report_gauge(:run_depth, scope.count) end |
.running_jobs_scope ⇒ Object
34 35 36 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 34 def self.running_jobs_scope Delayed::Job.running end |