Class: Sidekiq::Middlewares::OverrideElasticApmSpy

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/middlewares/override_elastic_apm_spy.rb

Overview

add more info to ElasticAPM metadata page

Instance Method Summary collapse

Instance Method Details

#call(_job_instance, options, _queue) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sidekiq/middlewares/override_elastic_apm_spy.rb', line 5

def call(_job_instance, options, _queue)
  worker_class = nil
  args = nil
  begin
    if options['class'].present?
      worker_class = options['class']
      args = options['args']
    else
      worker_class = options['args'].first['job_class']
      args = options['args'].first['arguments']
    end
  rescue
    worker_class = args = 'Unknown'
  end

  ElasticAPM.set_custom_context(
    sidekiq_context: {
      klass: worker_class,
      args: args
    }
  )

  yield
end