Module: EpsagonResqueModule::ClassMethods

Defined in:
lib/instrumentation/epsagon_resque_job.rb

Overview

Module to prepend to Resque singleton class

Instance Method Summary collapse

Instance Method Details

#configObject



45
46
47
# File 'lib/instrumentation/epsagon_resque_job.rb', line 45

def config
  EpsagonResqueInstrumentation.instance.config
end

#push(queue, item) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/instrumentation/epsagon_resque_job.rb', line 12

def push(queue, item)
  epsagon_conf = config[:epsagon] || {}
  # Check if the job is being wrapped by ActiveJob
  # before retrieving the job class name
  job_class = if item[:class] == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' && item[:args][0]&.is_a?(Hash)
                item[:args][0]['job_class']
              else
                item[:class]
              end
  attributes = {
    'operation' => 'enqueue',
    '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]
  }
  unless epsagon_conf[:metadata_only]
    attributes.merge!({
      'messaging.resque.args' => item
    })
  end

  tracer.in_span(queue.to_s, attributes: attributes, kind: :producer) do
    OpenTelemetry.propagation.text.inject(item)
    super
  end
end

#tracerObject



41
42
43
# File 'lib/instrumentation/epsagon_resque_job.rb', line 41

def tracer
  EpsagonResqueInstrumentation.instance.tracer
end