Class: Skylight::Subscriber Private
- Includes:
- Util::Logging
- Defined in:
- lib/skylight/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
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
- #normalizers ⇒ Object readonly private
Instance Method Summary collapse
- #finish(name, _id, payload) ⇒ Object private
-
#initialize(config, instrumenter) ⇒ Subscriber
constructor
private
A new instance of Subscriber.
- #publish(name, *args) ⇒ Object private
- #publish_event(event) ⇒ Object private
- #register! ⇒ Object private
- #start(name, _id, payload) ⇒ Object private
- #unregister! ⇒ Object private
-
#with_trace(trace, &block) ⇒ Object
private
:nodoc:.
Methods included from Util::Logging
#config_for_logging, #debug, #error, #fmt, #info, #log, #log_context, #raise_on_error?, #t, #trace, #trace?, #warn
Constructor Details
#initialize(config, instrumenter) ⇒ 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.
8 9 10 11 12 13 |
# File 'lib/skylight/subscriber.rb', line 8 def initialize(config, instrumenter) @config = config @normalizers = Normalizers.build(config) @instrumenter = instrumenter @subscribers = [] end |
Instance Attribute Details
#config ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/skylight/subscriber.rb', line 6 def config @config end |
#normalizers ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/skylight/subscriber.rb', line 6 def normalizers @normalizers 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.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/skylight/subscriber.rb', line 60 def finish(name, _id, payload) return if @instrumenter.disabled? return unless (trace = current_trace) while (curr = trace.notifications.pop) next unless curr.name == name = {} [:exception] = payload[:exception] if payload[:exception] [:exception_object] = payload[:exception_object] if payload[:exception_object] trace.done(curr.span, ) if curr.span normalize_after(trace, curr.span, name, payload) return end rescue Exception => e error "Subscriber#finish error; msg=%s", e. debug "trace=%s", trace.inspect debug "in: name=%s", name.inspect debug "in: payload=%s", payload.inspect t { e.backtrace.join("\n") } nil end |
#publish(name, *args) ⇒ 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.
83 84 85 |
# File 'lib/skylight/subscriber.rb', line 83 def publish(name, *args) # Ignored for now because nothing in rails uses it end |
#publish_event(event) ⇒ 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.
87 88 89 |
# File 'lib/skylight/subscriber.rb', line 87 def publish_event(event) # Ignored for now because only ActiveRecord::FutureResult uses it and we handle that with probes 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.
15 16 17 18 |
# File 'lib/skylight/subscriber.rb', line 15 def register! unregister! @normalizers.each_key { |key| @subscribers << ActiveSupport::Notifications.subscribe(key, 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.
53 54 55 56 57 58 |
# File 'lib/skylight/subscriber.rb', line 53 def start(name, _id, payload) return if @instrumenter.disabled? return unless (trace = current_trace) _start(trace, name, payload) 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.
20 21 22 |
# File 'lib/skylight/subscriber.rb', line 20 def unregister! ActiveSupport::Notifications.unsubscribe @subscribers.shift until @subscribers.empty? end |
#with_trace(trace, &block) ⇒ 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.
:nodoc:
43 44 45 46 47 48 49 50 51 |
# File 'lib/skylight/subscriber.rb', line 43 def with_trace(trace, &block) # :nodoc: Thread.handle_interrupt(EXCEPTION_NEVER) do previous_trace = @trace @trace = trace Thread.handle_interrupt(EXCEPTION_IMMEDIATE, &block) ensure @trace = previous_trace end end |