Method: NewRelic::Agent::Instrumentation::Sidekiq::Server#call

Defined in:
lib/new_relic/agent/instrumentation/sidekiq/server.rb

#call(worker, msg, queue, *_) ⇒ Object

Client middleware has additional parameters, and our tests use the middleware client-side to work inline.

[View source]

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/new_relic/agent/instrumentation/sidekiq/server.rb', line 17

def call(worker, msg, queue, *_)
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  trace_args = if worker.respond_to?(:newrelic_trace_args)
    worker.newrelic_trace_args(msg, queue)
  else
    self.class.default_trace_args(msg)
  end
  trace_headers = msg.delete(NewRelic::NEWRELIC_KEY)

  perform_action_with_newrelic_trace(trace_args) do
    NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(
      NewRelic::Agent::AttributePreFiltering.pre_filter(msg['args'], self.class.nr_attribute_options),
      ATTRIBUTE_JOB_NAMESPACE,
      NewRelic::Agent::AttributeFilter::DST_NONE
    )

    if ::NewRelic::Agent.config[:'distributed_tracing.enabled'] && trace_headers&.any?
      ::NewRelic::Agent::DistributedTracing::accept_distributed_trace_headers(trace_headers, 'Other')
    end

    yield
  end
end