Class: NewRelic::Agent::Instrumentation::Sidekiq::Server
- Inherits:
-
Object
- Object
- NewRelic::Agent::Instrumentation::Sidekiq::Server
- Includes:
- ControllerInstrumentation, Sidekiq::ServerMiddleware
- Defined in:
- lib/new_relic/agent/instrumentation/sidekiq/server.rb
Constant Summary collapse
- ATTRIBUTE_BASE_NAMESPACE =
'sidekiq.args'- ATTRIBUTE_FILTER_TYPES =
%i[include exclude].freeze
- ATTRIBUTE_JOB_NAMESPACE =
:"job.#{ATTRIBUTE_BASE_NAMESPACE}"
- INSTRUMENTATION_NAME =
'SidekiqServer'
Constants included from ControllerInstrumentation
ControllerInstrumentation::NR_DEFAULT_OPTIONS, ControllerInstrumentation::NR_DO_NOT_TRACE_KEY, ControllerInstrumentation::NR_IGNORE_APDEX_KEY, ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY
Class Method Summary collapse
Instance Method Summary collapse
-
#call(worker, msg, queue, *_) ⇒ Object
Client middleware has additional parameters, and our tests use the middleware client-side to work inline.
Methods included from ControllerInstrumentation
included, #perform_action_with_newrelic_trace
Methods included from ControllerInstrumentation::ClassMethods
add_transaction_tracer, #already_added_transaction_tracer?, #build_method_names, #generate_argument_list, newrelic_ignore, newrelic_ignore_apdex, #newrelic_ignore_aspect, newrelic_ignore_enduser, #newrelic_read_attr, #newrelic_write_attr, #parse_punctuation
Class Method Details
.default_trace_args(msg) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/new_relic/agent/instrumentation/sidekiq/server.rb', line 58 def self.default_trace_args(msg) { :name => 'perform', :class_name => msg['class'], :category => 'OtherTransaction/SidekiqJob' } end |
.nr_attribute_options ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/new_relic/agent/instrumentation/sidekiq/server.rb', line 66 def self. @nr_attribute_options ||= begin ATTRIBUTE_FILTER_TYPES.each_with_object({}) do |type, opts| pattern = NewRelic::Agent::AttributePreFiltering.formulate_regexp_union(:"#{ATTRIBUTE_BASE_NAMESPACE}.#{type}") opts[type] = pattern if pattern end.merge(attribute_namespace: ATTRIBUTE_JOB_NAMESPACE) end end |
Instance Method Details
#call(worker, msg, queue, *_) ⇒ Object
Client middleware has additional parameters, and our tests use the middleware client-side to work inline.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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_args[:notice_error] = false if NewRelic::Agent.config[:'sidekiq.ignore_retry_errors'] trace_headers = msg.delete(NewRelic::NEWRELIC_KEY) if NewRelic::Agent.config[:'sidekiq.separate_transactions'] current_txn = NewRelic::Agent::Tracer.current_transaction # Only finish if there's an active unfinished web transaction # This preserves normal behavior for background-to-background nesting if current_txn&.recording_web_transaction? && !current_txn.finished? current_txn.finish end end execution_block = proc do NewRelic::Agent::Transaction.merge_untrusted_agent_attributes( NewRelic::Agent::AttributePreFiltering.pre_filter(msg['args'], self.class.), 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 perform_action_with_newrelic_trace(trace_args, &execution_block) end |