class StackifyRubyAPM::Subscriber
@api private
Constants
- Notification
AS::Notifications API
Public Class Methods
new(agent)
click to toggle source
# File lib/stackify_apm/subscriber.rb, line 14 def initialize(agent) debug '[Subscriber] initialize(agent)' if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0' @agent = agent @normalizers = Normalizers.build(agent.config) end
Public Instance Methods
call(name, started, finished, id, payload)
click to toggle source
- call
-
Called when the rails version is 3.x
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
# File lib/stackify_apm/subscriber.rb, line 39 def call(name, started, finished, id, payload) return unless (transaction = @agent.current_transaction) normalized = @normalizers.normalize(transaction, name, payload) if started span = if normalized == :skip nil else name, type, context = normalized @agent.span(name, type, context: context) end transaction.notifications << Notification.new(id, span) end # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:disable Style/GuardClause if finished while (notification = transaction.notifications.pop) next unless notification.id == id if (span = notification.span) span.done end return end end # rubocop:enable Style/GuardClause end
finish(_name, id, _payload)
click to toggle source
- finish
-
Called when the rails version is NOT 3.x
# File lib/stackify_apm/subscriber.rb, line 88 def finish(_name, id, _payload) return unless (transaction = @agent.current_transaction) while (notification = transaction.notifications.pop) next unless notification.id == id if (span = notification.span) span.done end return end end
register!()
click to toggle source
# File lib/stackify_apm/subscriber.rb, line 20 def register! unregister! if @subscription @subscription = ActiveSupport::Notifications.subscribe(notifications_regex, self) end
start(name, id, payload)
click to toggle source
- start
-
Called when the rails version is NOT 3.x
# File lib/stackify_apm/subscriber.rb, line 71 def start(name, id, payload) return unless (transaction = @agent.current_transaction) normalized = @normalizers.normalize(transaction, name, payload) span = if normalized == :skip nil else name, type, context = normalized @agent.span(name, type, context: context) end transaction.notifications << Notification.new(id, span) end
unregister!()
click to toggle source
# File lib/stackify_apm/subscriber.rb, line 27 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end
Private Instance Methods
notifications_regex()
click to toggle source
# File lib/stackify_apm/subscriber.rb, line 103 def notifications_regex @notifications_regex ||= /(#{@normalizers.keys.join('|')})/ end