class ElasticAPM::Subscriber
@api private
Constants
- Notification
AS::Notifications API
Public Class Methods
new(agent)
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 10 def initialize(agent) @agent = agent @normalizers = Normalizers.build(agent.config) end
Public Instance Methods
finish(_name, id, _payload)
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 48 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
register!()
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 15 def register! unregister! if @subscription @subscription = ActiveSupport::Notifications.subscribe(notifications_regex, self) end
start(name, id, payload)
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 31 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
unregister!()
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 22 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end
Private Instance Methods
notifications_regex()
click to toggle source
# File lib/elastic_apm/subscriber.rb, line 64 def notifications_regex @notifications_regex ||= /(#{@normalizers.keys.join('|')})/ end