class ElasticAPM::Subscriber
@api private
def finish(_name, id, _payload)
def finish(_name, id, _payload) # debug "AS::Notification#finish:#{name}:#{id}" return unless (transaction = @agent.current_transaction) while (notification = transaction.notifications.pop) next unless notification.id == id if (span = notification.span) @agent.end_span if span == @agent.current_span end return end end
def initialize(agent)
def initialize(agent) @agent = agent @normalizers = Normalizers.build(agent.config) end
def notifications_regex
def notifications_regex @notifications_regex ||= /(#{@normalizers.keys.join('|')})/ end
def register!
def register! unregister! if @subscription @subscription = ActiveSupport::Notifications.subscribe(notifications_regex, self) end
def start(name, id, payload)
def start(name, id, payload) # debug "AS::Notification#start:#{name}:#{id}" return unless (transaction = @agent.current_transaction) normalized = @normalizers.normalize(transaction, name, payload) span = if normalized == :skip nil else name, type, context = normalized @agent.start_span(name, type, context: context) end transaction.notifications << Notification.new(id, span) end
def unregister!
def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end