module Oboe::Inst::ResqueWorker
Public Instance Methods
perform_with_oboe(job)
click to toggle source
# File lib/oboe/inst/resque.rb, line 80 def perform_with_oboe(job) report_kvs = {} last_arg = nil begin report_kvs[:Op] = :perform # Set these keys for the ability to separate out # background tasks into a separate app on the server-side UI report_kvs[:Controller] = :Resque report_kvs[:Action] = :perform report_kvs['HTTP-Host'] = Socket.gethostname report_kvs[:URL] = '/resque/' + job.queue report_kvs[:Method] = 'NONE' report_kvs[:Queue] = job.queue report_kvs[:Class] = job.payload['class'] if Oboe::Config[:resque][:log_args] kv_args = job.payload['args'].to_json # Limit the argument json string to 1024 bytes if kv_args.length > 1024 report_kvs[:Args] = kv_args[0..1023] + '...[snipped]' else report_kvs[:Args] = kv_args end end last_arg = job.payload['args'].last rescue end if last_arg.is_a?(Hash) && last_arg.key?('parent_trace_id') begin # Since the enqueue was traced, we force trace the actual job execution and reference # the enqueue trace with ParentTraceID report_kvs[:ParentTraceID] = last_arg['parent_trace_id'] job.payload['args'].pop rescue end # Force this trace regardless of sampling rate so that child trace can be # link to parent trace. Oboe::API.start_trace('resque-worker', nil, report_kvs.merge('Force' => true)) do perform_without_oboe(job) end else Oboe::API.start_trace('resque-worker', nil, report_kvs) do perform_without_oboe(job) end end end