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
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
- #register! ⇒ Object private
- #start(name, id, payload) ⇒ Object private
- #unregister! ⇒ Object private
Methods included from Util::Logging
#debug, #error, #info, #log, #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 @subscriber = nil @normalizers = Normalizers.build(config) @instrumenter = instrumenter 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 |
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.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/skylight/subscriber.rb', line 61 def finish(name, id, payload) return if @instrumenter.disabled? return unless trace = @instrumenter.current_trace while curr = trace.notifications.pop if curr.name == name trace.done(curr.span) if curr.span return end 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.
81 82 83 |
# File 'lib/skylight/subscriber.rb', line 81 def publish(name, *args) # Ignored for now because nothing in rails uses it 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! if @subscriber @subscriber = ActiveSupport::Notifications.subscribe nil, 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/skylight/subscriber.rb', line 39 def start(name, id, payload) return if @instrumenter.disabled? return unless trace = @instrumenter.current_trace cat, title, desc, annot = normalize(trace, name, payload) unless cat == :skip span = trace.instrument(cat, title, desc, annot) end trace.notifications << Notification.new(name, span) rescue Exception => e error "Subscriber#start error; msg=%s", e. debug "trace=%s", trace.inspect debug "in: name=%s", name.inspect debug "in: payload=%s", payload.inspect debug "out: cat=%s, title=%s, desc=%s", cat.inspect, name.inspect, desc.inspect debug "out: annot=%s", annot.inspect t { e.backtrace.join("\n") } nil 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 23 |
# File 'lib/skylight/subscriber.rb', line 20 def unregister! ActiveSupport::Notifications.unsubscribe @subscriber @subscriber = nil end |