Class: Cron::RecordDelayedJobMetrics
- Inherits:
-
Job
- Object
- ActiveJob::Base
- ApplicationJob
- Job
- Cron::RecordDelayedJobMetrics
- Defined in:
- lib/app/jobs/cron/record_delayed_job_metrics.rb
Overview
Take care of job metrics
Instance Attribute Summary
Attributes inherited from ApplicationJob
Instance Method Summary collapse
-
#execute ⇒ Object
Main driver method.
Methods inherited from Job
cron_tab_entry, #notify_job_failure, #send_support_email
Methods inherited from ApplicationJob
#duration, #parse_payload, #perform, valid_environment?, valid_environments
Methods included from App47Logger
clean_params, #clean_params, delete_parameter_keys, #log_controller_error, log_debug, #log_debug, log_error, #log_error, log_exception, #log_message, log_message, #log_warn, log_warn, mask_parameter_keys, #update_flash_messages
Instance Method Details
#execute ⇒ Object
Main driver method
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/app/jobs/cron/record_delayed_job_metrics.rb', line 13 def execute Delayed::Jobs::Run.each do |run| metric = Delayed::Jobs::Metric.find_or_create_by! name: run.name metric.set count: metric.count + 1, total: run.duration + metric.total, max: [metric.max, run.duration].max, min: [metric.min, run.duration].min, last_run_at: [run.locked_at, metric.last_run_at].compact.max run.destroy! end end |