Module: ActiveJobMetadata::Timing
- Extended by:
- ActiveSupport::Concern
- Includes:
- Metadata
- Included in:
- All
- Defined in:
- lib/active_job_metadata/timing.rb
Overview
Use Timing to track and report on execution times.
Instance Method Summary collapse
-
#queue_duration ⇒ Object
The queue duration is the time in seconds a job spent in the queue before it was processed.
-
#total_duration ⇒ Object
The total duration is the sum of the queue and working duration.
-
#working_duration ⇒ Object
The working duration is the time in seconds a job spent in the process method.
Methods included from Metadata
#metadata, #metadata=, #save_metadata
Instance Method Details
#queue_duration ⇒ Object
The queue duration is the time in seconds a job spent in the queue before it was processed. If it has not been enqueued or processing has not yet begun, it will return nil.
20 21 22 23 |
# File 'lib/active_job_metadata/timing.rb', line 20 def queue_duration return nil unless enqueued_at && started_at started_at - enqueued_at end |
#total_duration ⇒ Object
The total duration is the sum of the queue and working duration. This gives a measure of how long it took from enqueuing the job to completing all processing.
36 37 38 39 40 41 42 |
# File 'lib/active_job_metadata/timing.rb', line 36 def total_duration q = queue_duration w = working_duration return nil unless q && w queue_duration + working_duration end |
#working_duration ⇒ Object
The working duration is the time in seconds a job spent in the process method. If process has not yet been called, or process has not finished it will return nil.
28 29 30 31 |
# File 'lib/active_job_metadata/timing.rb', line 28 def working_duration return nil unless done_at && started_at done_at - started_at end |