Skip to content

Display job duration for finished ones #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025
Merged

Conversation

morgoth
Copy link
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>'

@@ -47,11 +47,17 @@
<% end %>
<% if job.finished_at.present? %>
<tr>
<th>Finished at</th>
<th>Finished</th>
Copy link
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