Class: Toy::Instrumentation::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/toy/instrumentation/subscriber.rb

Direct Known Subclasses

MetriksSubscriber, StatsdSubscriber

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, start, ending, transaction_id, payload) ⇒ Subscriber

Private: Initializes a new event processing instance.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/toy/instrumentation/subscriber.rb', line 12

def initialize(name, start, ending, transaction_id, payload)
  @name = name
  @start = start
  @ending = ending
  @payload = payload
  @duration = ending - start
  @transaction_id = transaction_id

  @action = @name.split('.').first
  @model = @payload[:model]
end

Class Method Details

.call(name, start, ending, transaction_id, payload) ⇒ Object

Public: Use this as the subscribed block.



7
8
9
# File 'lib/toy/instrumentation/subscriber.rb', line 7

def self.call(name, start, ending, transaction_id, payload)
  new(name, start, ending, transaction_id, payload).update
end

Instance Method Details

#updateObject

Public: Actually update all the timers for the event.

Returns nothing.



27
28
29
30
# File 'lib/toy/instrumentation/subscriber.rb', line 27

def update
  update_timer "toystore.#{@action}"
  update_timer "toystore.#{@model}.#{@action}"
end

#update_timer(metric) ⇒ Object

Internal: Override in subclass.



33
34
35
# File 'lib/toy/instrumentation/subscriber.rb', line 33

def update_timer(metric)
  raise 'not implemented'
end