Class: ElasticAPM::Subscriber Private
- Inherits:
-
Object
- Object
- ElasticAPM::Subscriber
- Includes:
- Logging
- Defined in:
- lib/elastic_apm/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
-
#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.
11 12 13 14 |
# File 'lib/elastic_apm/subscriber.rb', line 11 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/elastic_apm/subscriber.rb', line 49 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! ⇒ 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.
16 17 18 19 20 21 |
# File 'lib/elastic_apm/subscriber.rb', line 16 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/elastic_apm/subscriber.rb', line 32 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! ⇒ 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.
23 24 25 26 |
# File 'lib/elastic_apm/subscriber.rb', line 23 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end |