Where is the class Job defined?

36 views
Skip to first unread message

Martin Streicher

unread,
Oct 20, 2022, 12:42:16 PM10/20/22
to delayed_job
I am digging through the DJ source code to figure out how to better monitor it. One thing stumps me: Where is the module or class `Job` as in `Delayed::Job` defined? Code can call methods on it, so I assume it exists somewhere?


Robert Mathews

unread,
Oct 20, 2022, 2:04:41 PM10/20/22
to delay...@googlegroups.com
It's not hard to monitor it, at least at a simple level. Just query the delayed_jobs table via SQL.

For example, the size of queue is Delayed::Job.count and/or "select count(*) from delayed_jobs".

You can further refine your monitoring by getting counts by depriority and/or queue_name.

I've never needed to do any more.


On Thu, Oct 20, 2022 at 12:42 PM Martin Streicher <martin.s...@gadget.consulting> wrote:
I am digging through the DJ source code to figure out how to better monitor it. One thing stumps me: Where is the module or class `Job` as in `Delayed::Job` defined? Code can call methods on it, so I assume it exists somewhere?


--

---
You received this message because you are subscribed to the Google Groups "delayed_job" group.
To unsubscribe from this group and stop receiving emails from it, send an email to delayed_job...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/delayed_job/353c0a9b-a964-4fc2-8595-b72f8ad444f4n%40googlegroups.com.

Martin Streicher

unread,
Oct 20, 2022, 5:39:54 PM10/20/22
to delayed_job
To answer my own question... the `Job` of Delayed::Job is defined in the adapter providing a data store to AJ. For me, using Active Record for the data store, `Job` is defined in the active_job_active_record gem. 

I agree about the queues themselves -- easy to monitor from the database. I was interested in tracking the workers, including across several machines. I found the method I would like to hook into in the active_job_active_record gem, but I cannot seem to apply a Ruby refinement to the method. I may have to resort -- gasp! -- an old school monkey-patch to hook in. 

I also am considering the addition of monit to keep the workers running in the event of a crash. 
Reply all
Reply to author
Forward
0 new messages