refactor(job): wrap sentry tags in a single before_perform
This commit is contained in:
parent
17f5fb4a51
commit
3939f85860
3 changed files with 11 additions and 8 deletions
|
@ -5,6 +5,17 @@ class ApplicationJob < ActiveJob::Base
|
|||
|
||||
attr_writer :request_id
|
||||
|
||||
before_perform do |job|
|
||||
arg = job.arguments.first
|
||||
|
||||
case arg
|
||||
when Dossier
|
||||
Sentry.set_tags(dossier: arg.id, procedure: arg.procedure.id)
|
||||
when Procedure
|
||||
Sentry.set_tags(procedure: arg.id)
|
||||
end
|
||||
end
|
||||
|
||||
around_perform do |job, block|
|
||||
Rails.logger.info("#{job.class.name} started at #{Time.zone.now}")
|
||||
Current.set(request_id: job.request_id) do
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
class ArchiveCreationJob < ApplicationJob
|
||||
queue_as :archives
|
||||
|
||||
before_perform do |job|
|
||||
Sentry.set_tags(procedure: job.arguments.first.id)
|
||||
end
|
||||
|
||||
def max_run_time
|
||||
Archive::MAX_DUREE_GENERATION
|
||||
end
|
||||
|
|
|
@ -3,10 +3,6 @@ class ExportJob < ApplicationJob
|
|||
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
before_perform do |job|
|
||||
Sentry.set_tags(procedure: job.arguments.first.procedure.id)
|
||||
end
|
||||
|
||||
def max_run_time
|
||||
Export::MAX_DUREE_GENERATION
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue