class Opbeat::Subscriber
@api private
Attributes
config[R]
Public Class Methods
new(config, client)
click to toggle source
# File lib/opbeat/subscriber.rb, line 9 def initialize config, client @config = config @client = client @normalizers = Normalizers.build config end
Public Instance Methods
finish(name, id, payload)
click to toggle source
# File lib/opbeat/subscriber.rb, line 58 def finish name, id, payload return unless transaction = @client.current_transaction while notification = transaction.notifications.pop if notification.id == id if trace = notification.trace trace.done end return end end end
register!()
click to toggle source
# File lib/opbeat/subscriber.rb, line 17 def register! unregister! if @subscription @subscription = ActiveSupport::Notifications.subscribe actions_regex, self end
start(name, id, payload)
click to toggle source
# File lib/opbeat/subscriber.rb, line 37 def start name, id, payload return unless transaction = @client.current_transaction normalized = @normalizers.normalize(transaction, name, payload) trace = nil unless normalized == :skip sig, kind, extra = normalized trace = Trace.new(transaction, sig, kind, transaction.running_traces, extra) offset = transaction.current_offset transaction.traces << trace trace.start offset end transaction.notifications << Notification.new(id, trace) end
unregister!()
click to toggle source
# File lib/opbeat/subscriber.rb, line 22 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end
Private Instance Methods
actions_regex()
click to toggle source
# File lib/opbeat/subscriber.rb, line 73 def actions_regex @actions_regex ||= Regexp.new( "(".freeze + @normalizers.keys.join("|".freeze) + ")".freeze ) end