class NewRelic::Agent::Instrumentation::ActionMailerSubscriber
NOTE: as of v7.1.0.0.alpha, deliver.action_mailer will provide an empty payload hash ({}) to start
, so in this subscriber class we defer params population until finish
and start the segment with a temporary name that is later replaced
Constants
- BASE_NAME
- METHOD_NAME_MAPPING
- PATTERN
- PAYLOAD_KEYS
- UNKNOWN_MAILER
Public Instance Methods
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 36 def finish(name, id, payload) return unless state.is_execution_traced? finish_segment(id, payload) rescue => e log_notification_error(e, name, 'finish') end
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 28 def start(name, id, payload) return unless state.is_execution_traced? start_segment(name, id, payload) rescue => e log_notification_error(e, name, 'start') end
Private Instance Methods
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 51 def finish_segment(id, payload) segment = pop_segment(id) return unless segment if segment.name.match?(UNKNOWN_MAILER) && payload.key?(:mailer) segment.name = segment.name.sub(UNKNOWN_MAILER, "#{BASE_NAME}/#{payload[:mailer]}/") end PAYLOAD_KEYS.each do |key| segment.params[key] = payload[key] if payload.key?(key) end notice_exception(segment, payload) segment.finish end
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 79 def method_from_name(name) METHOD_NAME_MAPPING[name] end
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 73 def metric_name(name, payload) mailer = payload[:mailer] || UNKNOWN method = method_from_name(name) "#{BASE_NAME}/#{mailer}/#{method}" end
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 67 def notice_exception(segment, payload) if exception = exception_object(payload) segment.notice_error(exception) end end
Source
# File lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb, line 46 def start_segment(name, id, payload) segment = Tracer.start_segment(name: metric_name(name, payload)) push_segment(id, segment) end