Improve active job context when using Delayed Job or Resque #671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
Delayed Job
The current context for Delayed Job uses the
display_name
method, if implemented. Rails implementsdisplay_name
internally to help debugging, but this uses the job ID and arguments which makes it unusable as an event's context because the same job will have different contexts between executionsThis PR avoids using
display_name
if it matches the Rails format and will use the same context that we use in other queuing libraries instead (JobName@queue_name
)Resque
The Resque integration reads the class name from the payload data and uses that as context. When run in Active Job the class name is always the Resque wrapper:
ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper
. This leads to the same context being used across different jobsWe will now "unwrap" the actual job class and use that instead, e.g.
SomeJob@some_queue
Testing
Existing tests cover breaks from this change & a new unit test has been added for Resque. We currently don't have unit tests for Delayed Job, but this will be covered by a Maze Runner test in #672