Class: SolidApm::SpanSubscriber::Base
- Inherits:
-
Object
- Object
- SolidApm::SpanSubscriber::Base
- Defined in:
- app/models/solid_apm/span_subscriber/base.rb
Direct Known Subclasses
ActionDispatch, ActionViewRender, ActiveRecordSql, ActiveSupportCache, NetHttp
Class Method Summary collapse
Class Method Details
.inherited(subclass) ⇒ Object
12 13 14 |
# File 'app/models/solid_apm/span_subscriber/base.rb', line 12 def self.inherited(subclass) subscribers << subclass end |
.subscribe ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/solid_apm/span_subscriber/base.rb', line 20 def self.subscribe ActiveSupport::Notifications.subscribe(self::PATTERN) do |name, start, finish, id, payload| next unless SpanSubscriber::Base.transaction subtype, type = name.split('.') duration = ((finish.to_f - start.to_f) * 1000).round(6) span = { uuid: SecureRandom.uuid, sequence: SpanSubscriber::Base.spans.size + 1, timestamp: start, end_time: finish, duration: duration, name: name, type: type, subtype: subtype, summary: self.new.summary(payload), } SpanSubscriber::Base.spans << span # Allow the subscriber to yield additional spans, like ending the transaction yield(name, start, finish, id, payload) if block_given? end end |
.subscribe! ⇒ Object
16 17 18 |
# File 'app/models/solid_apm/span_subscriber/base.rb', line 16 def self.subscribe! subscribers.each(&:subscribe) end |