refactor(job): wrap sentry tags in a single before_perform

This commit is contained in:
Colin Darie 2023-06-13 16:27:16 +02:00
parent 17f5fb4a51
commit 3939f85860
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 11 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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