Skip to content

Display job duration for finished ones#264

Merged
rosa merged 1 commit intorails:mainfrom
morgoth:add-duration
Jul 11, 2025
Merged

Display job duration for finished ones#264
rosa merged 1 commit intorails:mainfrom
morgoth:add-duration

Conversation

@morgoth
Copy link
Copy Markdown
Member

@morgoth morgoth commented Jun 11, 2025

To help discover which jobs are fast/slow.

I tried to add a simple test:

module ActiveJob::QueueAdapters::AdapterTesting::JobDetails
  extend ActiveSupport::Testing::Declarative

  test "returns job duration" do
    DummyJob.perform_later
    perform_enqueued_jobs

    job = ActiveJob.jobs.last

    assert_job_proxy DummyJob, job
    assert job.job_id
  end
end

but this fails for both adapters with:

Error:
ActiveJob::QueueAdapters::ResqueTest#test_returns_job_duration:
NoMethodError: undefined method 'serialized_arguments' for nil
    test/active_job/queue_adapters/adapter_testing/job_details.rb:11:in 'block in <module:JobDetails>'
Error:
ActiveJob::QueueAdapters::SolidQueueTest#test_returns_job_duration:
ActiveJob::Errors::QueryError: Status not supported: 
    lib/active_job/queue_adapters/solid_queue_ext.rb:231:in 'ActiveJob::QueueAdapters::SolidQueueExt::SolidQueueJobs#execution_class_by_status'
    lib/active_job/queue_adapters/solid_queue_ext.rb:179:in 'ActiveJob::QueueAdapters::SolidQueueExt::SolidQueueJobs#executions'
    lib/active_job/queue_adapters/solid_queue_ext.rb:151:in 'ActiveJob::QueueAdapters::SolidQueueExt::SolidQueueJobs#jobs'
    lib/active_job/queue_adapters/solid_queue_ext.rb:51:in 'ActiveJob::QueueAdapters::SolidQueueExt#fetch_jobs'
    lib/active_job/jobs_relation.rb:256:in 'ActiveJob::JobsRelation#perform_each'
    lib/active_job/jobs_relation.rb:243:in 'ActiveJob::JobsRelation#load_jobs'
    lib/active_job/jobs_relation.rb:125:in 'ActiveJob::JobsRelation#each'
    lib/active_job/jobs_relation.rb:31:in 'Enumerable#to_a'
    lib/active_job/jobs_relation.rb:31:in 'ActiveJob::JobsRelation#last'
    test/active_job/queue_adapters/adapter_testing/job_details.rb:9:in 'block in <module:JobDetails>'

<% if job.finished_at.present? %>
<tr>
<th>Finished at</th>
<th>Finished</th>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed for consistency with Enqueued and Scheduled

@rosa rosa merged commit 1cfb47f into rails:main Jul 11, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants