Class: Rubevent::Metrics

Inherits:
Object
  • Object
show all
Defined in:
lib/rubevent/metrics.rb

Instance Method Summary collapse

Constructor Details

#initializeMetrics

Returns a new instance of Metrics.



3
4
5
6
7
# File 'lib/rubevent/metrics.rb', line 3

def initialize
  @events_processed = {}
  @events_received = {}
  @listeners_registered = {}
end

Instance Method Details

#events_processed(event_type = nil) ⇒ Object



17
18
19
# File 'lib/rubevent/metrics.rb', line 17

def events_processed(event_type = nil)
  calc_hash @events_processed, event_type
end

#events_received(event_type = nil) ⇒ Object



13
14
15
# File 'lib/rubevent/metrics.rb', line 13

def events_received(event_type = nil)
  calc_hash(@events_received, event_type)
end

#loop_size(event_type = nil) ⇒ Object



9
10
11
# File 'lib/rubevent/metrics.rb', line 9

def loop_size(event_type = nil)
   events_received(event_type) - events_processed(event_type)
end

#mark_processed(event_type) ⇒ Object



25
26
27
# File 'lib/rubevent/metrics.rb', line 25

def mark_processed event_type
  update_hash @events_processed, event_type
end

#num_listeners(event_type = nil) ⇒ Object



21
22
23
# File 'lib/rubevent/metrics.rb', line 21

def num_listeners(event_type = nil)
  calc_hash @listeners_registered, event_type
end

#received(event_type) ⇒ Object



29
30
31
# File 'lib/rubevent/metrics.rb', line 29

def received event_type
  update_hash @events_received, event_type
end

#registered(event_type) ⇒ Object



33
34
35
# File 'lib/rubevent/metrics.rb', line 33

def registered event_type
  update_hash @listeners_registered, event_type
end