Module: EpsagonResqueJob
- Defined in:
- lib/instrumentation/epsagon_resque_job.rb
Instance Method Summary collapse
-
#perform ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Instance Method Details
#perform ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/instrumentation/epsagon_resque_job.rb', line 52 def perform # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity inner_exception = nil epsagon_conf = config[:epsagon] || {} job_args = args || [] # Check if the job is being wrapped by ActiveJob # before retrieving the job class name job_class = if payload_class_name == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' && job_args[0]&.is_a?(Hash) job_args[0]['job_class'] else payload_class_name end attributes = { 'operation' => 'perform', 'messaging.system' => 'resque', 'messaging.resque.job_class' => job_class, 'messaging.destination' => queue.to_s, 'messaging.destination_kind' => 'queue', 'messaging.resque.redis_url' => Resque.redis.connection[:id] } runner_attributes = { 'type' => 'resque_worker', 'messaging.resque.redis_url' => Resque.redis.connection[:id], } extracted_context = OpenTelemetry.propagation.text.extract(@payload) unless epsagon_conf[:metadata_only] attributes.merge!({ 'messaging.resque.args' => args }) end tracer.in_span( queue.to_s, attributes: attributes, with_parent: extracted_context, kind: :consumer ) do |trigger_span| tracer.in_span(job_class, attributes: runner_attributes, kind: :consumer ) do |runner_span| super end rescue Exception => e inner_exception = e end raise inner_exception if inner_exception end |