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
5 6 7 8 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 5 def self.enable enable_run_depth enable_run_age end |
.enable_run_age ⇒ Object
15 16 17 18 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 15 def self.enable_run_age Periodic.enable_callbacks Periodic.add(-> { report_run_age }) end |
.enable_run_depth ⇒ Object
10 11 12 13 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 10 def self.enable_run_depth Periodic.enable_callbacks Periodic.add(-> { report_run_depth }) end |
.report_run_age ⇒ Object
25 26 27 28 29 30 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 25 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) end |
.report_run_depth ⇒ Object
20 21 22 23 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 20 def self.report_run_depth scope = running_jobs_scope Periodic.report_gauge(:run_depth, scope.count) end |
.running_jobs_scope ⇒ Object
32 33 34 |
# File 'lib/inst_jobs_statsd/stats/periodic/run.rb', line 32 def self.running_jobs_scope Delayed::Job.running end |