Class: Atatus::Subscriber Private
- Inherits:
-
Object
- Object
- Atatus::Subscriber
- Includes:
- Logging
- Defined in:
- lib/atatus/subscriber.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Notification
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Method Summary collapse
-
#finish(name, id, payload) ⇒ Object
private
rubocop:disable Metrics/CyclomaticComplexity.
-
#initialize(agent) ⇒ Subscriber
constructor
private
A new instance of Subscriber.
- #register! ⇒ Object private
- #start(name, id, payload) ⇒ Object private
- #unregister! ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(agent) ⇒ Subscriber
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Subscriber.
28 29 30 31 |
# File 'lib/atatus/subscriber.rb', line 28 def initialize(agent) @agent = agent @normalizers = Normalizers.build(agent.config) end |
Instance Method Details
#finish(name, id, payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/CyclomaticComplexity
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/atatus/subscriber.rb', line 73 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) if @agent.config.span_frames_min_duration? span.original_backtrace ||= @normalizers.backtrace(name, payload) end @agent.end_span if span == @agent.current_span end return end end |
#register! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 |
# File 'lib/atatus/subscriber.rb', line 33 def register! unregister! if @subscription @subscription = ActiveSupport::Notifications.subscribe(notifications_regex, self) end |
#start(name, id, payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/atatus/subscriber.rb', line 49 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, subtype, action, context = normalized @agent.start_span( name, type, subtype: subtype, action: action, context: context ) end transaction.notifications << Notification.new(id, span) end |
#unregister! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 |
# File 'lib/atatus/subscriber.rb', line 40 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end |