module SidekiqClientMiddlewareExtension

Public Instance Methods

call(_worker_class, job, _queue, _redis_pool) { || ... } click to toggle source
# File lib/epsagon.rb, line 170
def call(_worker_class, job, _queue, _redis_pool)
  config = OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance.config[:epsagon] || {}
  attributes = {
    'operation' => job['at'] ? 'perform_at' : 'perform_async',
    'messaging.system' => 'sidekiq',
    'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'],
    'messaging.message_id' => job['jid'],
    'messaging.destination' => job['queue'],
    'messaging.destination_kind' => 'queue',
    'messaging.sidekiq.redis_url' => Sidekiq.options['url'] || Util.redis_default_url
  }
  unless config[:metadata_only]
    attributes.merge!({
      'messaging.sidekiq.args' => JSON.dump(job['args'])
    })
  end
  tracer.in_span(
    job['queue'],
    attributes: attributes,
    kind: :producer
  ) do |span|
    OpenTelemetry.propagation.text.inject(job)
    span.add_event('created_at', timestamp: job['created_at'])
    Util.untraced {yield}
  end
end