Class: TraceView::SidekiqWorker
- Inherits:
-
Object
- Object
- TraceView::SidekiqWorker
- Defined in:
- lib/traceview/inst/sidekiq-worker.rb
Instance Method Summary collapse
Instance Method Details
#call(*args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/traceview/inst/sidekiq-worker.rb', line 34 def call(*args) # args: 0: worker, 1: msg, 2: queue report_kvs = collect_kvs(args) # Something is happening across Celluloid threads where liboboe settings # are being lost. So we re-set the tracing mode to assure # we sample as desired. Setting the tracing mode will re-update # the liboboe settings. TraceView::Config[:tracing_mode] = TraceView::Config[:tracing_mode] # Continue the trace from the enqueue side? if args[1].is_a?(Hash) && TraceView::XTrace.valid?(args[1]['SourceTrace']) report_kvs[:SourceTrace] = args[1]['SourceTrace'] # Pass the source trace in the TV-Meta flag field to indicate tracing report_kvs['X-TV-Meta'] = args[1]['SourceTrace'] end result = TraceView::API.start_trace(:'sidekiq-worker', nil, report_kvs) do yield end result[0] end |
#collect_kvs(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/traceview/inst/sidekiq-worker.rb', line 6 def collect_kvs(args) begin # Attempt to collect up pertinent info. If we hit something unexpected, # keep calm and instrument on. report_kvs = {} worker, msg, queue = args # Background Job Spec KVs report_kvs[:Spec] = :job report_kvs[:Flavor] = :sidekiq report_kvs[:Queue] = queue report_kvs[:Retry] = msg['retry'] report_kvs[:JobName] = worker.class.to_s report_kvs[:MsgID] = msg['jid'] report_kvs[:Args] = msg['args'].to_s[0..1024] if TV::Config[:sidekiqworker][:log_args] report_kvs[:Backtrace] = TV::API.backtrace if TV::Config[:sidekiqworker][:collect_backtraces] # Webserver Spec KVs report_kvs[:'HTTP-Host'] = Socket.gethostname report_kvs[:Controller] = "Sidekiq_#{queue}" report_kvs[:Action] = msg['class'] report_kvs[:URL] = "/sidekiq/#{queue}/#{msg['class']}" rescue => e TraceView.logger.warn "[traceview/sidekiq] Non-fatal error capturing KVs: #{e.}" end report_kvs end |