Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,4 @@ class ApplicationJob < ActiveJob::Base

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError

ActiveJob::Base.instance_eval do
retry_on StandardError, wait: :polynomially_longer, attempts: 10

before_enqueue do |job|
possible_context = job.arguments.last
next if possible_context.is_a?(Hash) && possible_context&.try(:key?, :sagittarius_context)

job.arguments << Code0::ZeroTrack::Context.current.to_h.merge(sagittarius_context: true)
end

around_perform do |job, block|
context = job.arguments.pop
context.delete(:sagittarius_context)
source_application = context.fetch(Code0::ZeroTrack::Context.log_key(:application), nil)
Code0::ZeroTrack::Context.with_context(
**context,
application: 'good_job',
source_application: source_application,
job_id: job.job_id,
job_class: self.class.name
) do
block.call
end
end
end
end
27 changes: 27 additions & 0 deletions config/initializers/active_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

ActiveJob::Base.instance_eval do
retry_on StandardError, wait: :polynomially_longer, attempts: 10

before_enqueue do |job|
possible_context = job.arguments.last
next if possible_context.is_a?(Hash) && possible_context&.try(:key?, :sagittarius_context)

job.arguments << Code0::ZeroTrack::Context.current.to_h.merge(sagittarius_context: true)
end

around_perform do |job, block|
context = job.arguments.pop
context.delete(:sagittarius_context)
source_application = context.fetch(Code0::ZeroTrack::Context.log_key(:application), nil)
Code0::ZeroTrack::Context.with_context(
**context,
application: 'good_job',
source_application: source_application,
job_id: job.job_id,
job_class: self.class.name
) do
block.call
end
end
end