Class: NewRelic::Agent::Instrumentation::ActiveJobSubscriber
- Inherits:
-
NotificationsSubscriber
- Object
- NotificationsSubscriber
- NewRelic::Agent::Instrumentation::ActiveJobSubscriber
- Defined in:
- lib/new_relic/agent/instrumentation/active_job_subscriber.rb
Constant Summary collapse
- PAYLOAD_KEYS =
%i[adapter db_runtime error job wait jobs]
- PATTERN =
/\A([^\.]+)\.active_job\z/- METHOD_NAME_MAPPING =
Hash.new do |h, k| if PATTERN =~ k h[k] = $1 else h[k] = NewRelic::UNKNOWN end end
Instance Method Summary collapse
- #add_segment_params(segment, payload) ⇒ Object
- #method_from_name(name) ⇒ Object
-
#metric_name(name, payload) ⇒ Object
NOTE: For ‘enqueue_all.active_job`, only the first job is used to determine the queue.
Methods inherited from NotificationsSubscriber
#define_exception_method, find_all_subscribers, #finish, #finish_segment, #initialize, #log_notification_error, #pop_segment, #push_segment, #segment_stack, #start, #start_segment, #state, subscribe, subscribed?
Constructor Details
This class inherits a constructor from NewRelic::Agent::Instrumentation::NotificationsSubscriber
Instance Method Details
#add_segment_params(segment, payload) ⇒ Object
13 14 15 16 17 |
# File 'lib/new_relic/agent/instrumentation/active_job_subscriber.rb', line 13 def add_segment_params(segment, payload) PAYLOAD_KEYS.each do |key| segment.params[key] = payload[key] if payload.key?(key) end end |
#method_from_name(name) ⇒ Object
39 40 41 |
# File 'lib/new_relic/agent/instrumentation/active_job_subscriber.rb', line 39 def method_from_name(name) METHOD_NAME_MAPPING[name] end |
#metric_name(name, payload) ⇒ Object
NOTE: For ‘enqueue_all.active_job`, only the first job is used to determine the queue. Therefore, this assumes all jobs given as arguments for perform_all_later share the same queue.
21 22 23 24 25 26 27 |
# File 'lib/new_relic/agent/instrumentation/active_job_subscriber.rb', line 21 def metric_name(name, payload) job = payload[:job] || payload[:jobs].first queue = job.queue_name method = method_from_name(name) "Ruby/ActiveJob/#{queue}/#{method}" end |