Class: StackifyRubyAPM::Subscriber Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::Subscriber
- Includes:
- Log
- Defined in:
- lib/stackify_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 Log
Instance Method Summary collapse
-
#call(name, started, finished, id, payload) ⇒ Object
private
- call
-
Called when the rails version is 3.x rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
-
#finish(_name, id, _payload) ⇒ Object
private
- finish
-
Called when the rails version is NOT 3.x.
-
#initialize(agent) ⇒ Subscriber
constructor
private
A new instance of Subscriber.
- #register! ⇒ Object private
-
#start(name, id, payload) ⇒ Object
private
- start
-
Called when the rails version is NOT 3.x.
- #unregister! ⇒ Object private
Methods included from Log
#debug, #error, #fatal, #info, #log, #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.
14 15 16 17 18 |
# 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 |
Instance Method Details
#call(name, started, finished, 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.
- call
-
Called when the rails version is 3.x
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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) ⇒ 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.
- finish
-
Called when the rails version is NOT 3.x
88 89 90 91 92 93 94 95 96 97 98 99 |
# 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! ⇒ 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.
20 21 22 23 24 25 |
# 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) ⇒ 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.
- start
-
Called when the rails version is NOT 3.x
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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! ⇒ 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.
27 28 29 30 |
# File 'lib/stackify_apm/subscriber.rb', line 27 def unregister! ActiveSupport::Notifications.unsubscribe @subscription @subscription = nil end |