Class: AppPerfRpm::SidekiqClient

Inherits:
Object
  • Object
show all
Defined in:
lib/app_perf_rpm/instruments/sidekiq.rb

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/app_perf_rpm/instruments/sidekiq.rb', line 46

def call(*args)
  worker, msg, queue = args

  if ::AppPerfRpm::Tracer.tracing?
    operation = "Sidekiq_#{queue}##{msg["wrapped"]}"
    span = AppPerfRpm.tracer.start_span(operation, tags: {
      "component" => "Sidekiq",
      "span.kind" => "client",
      "http.url" => "/sidekiq/#{queue}/#{msg['wrapped']}",
      "peer.address" => Socket.gethostname,
      "bg.queue" => queue,
      "bg.job_name" => worker.class.to_s
    })
    AppPerfRpm::Utils.log_source_and_backtrace(span, :sidekiq)

    inject(span, msg)
  end

  yield
rescue Exception => e
  if span
    span.set_tag('error', true)
    span.log_error(e)
  end
  raise
ensure
  span.finish if span
end