Sha256: b123fddd2b6ffbba0da658c313f3f4f694dfedfd8074e1cf0a4d8ebbfbb30116
Contents?: true
Size: 1.66 KB
Versions: 22
Compression:
Stored size: 1.66 KB
Contents
module Appsignal class Subscriber PROCESS_ACTION_PREFIX = 'process_action'.freeze PERFORM_JOB_PREFIX = 'perform_job'.freeze BLANK = ''.freeze def initialize subscribe end def subscribe Appsignal.logger.debug('Subscribing to notifications') # Subscribe to notifications that don't start with a ! ActiveSupport::Notifications.subscribe(/^[^!]/, self) end def unsubscribe Appsignal.logger.debug('Unsubscribing from notifications') ActiveSupport::Notifications.unsubscribe(self) end def resubscribe Appsignal.logger.debug('Resubscribing to notifications') unsubscribe subscribe end def publish(name, *args) # Not used, it's part of AS notifications but is not used in Rails # and it seems to be unclear what it's function is. See: # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications/fanout.rb#L49 end def start(name, id, payload) return unless transaction = Appsignal::Transaction.current return if transaction.paused? Appsignal::Extension.start_event(transaction.transaction_index) end def finish(name, id, payload) return unless transaction = Appsignal::Transaction.current if name.start_with?(PROCESS_ACTION_PREFIX, PERFORM_JOB_PREFIX) transaction.set_root_event(name, payload) end return if transaction.paused? title, body = Appsignal::EventFormatter.format(name, payload) Appsignal::Extension.finish_event( transaction.transaction_index, name, title || BLANK, body || BLANK ) end end end
Version data entries
22 entries across 22 versions & 1 rubygems