class Adhearsion::Statistics
Public Class Methods
new()
click to toggle source
# File lib/adhearsion/statistics.rb, line 44 def initialize @calls_dialed = @calls_offered = @calls_routed = @calls_rejected = 0 @calls_by_route = Hash.new { |h,k| h[k] = 0 } end
setup_event_handlers()
click to toggle source
@private
# File lib/adhearsion/statistics.rb, line 10 def self.setup_event_handlers Events.punchblock(Punchblock::Event::Offer) do begin Celluloid::Actor[:statistics].register_call_offered ensure throw :pass end end Events.call_dialed do begin Celluloid::Actor[:statistics].register_call_dialed ensure throw :pass end end Events.call_rejected do begin Celluloid::Actor[:statistics].register_call_rejected ensure throw :pass end end Events.call_routed do |data| begin Celluloid::Actor[:statistics].register_call_routed data ensure throw :pass end end end
Public Instance Methods
dump()
click to toggle source
Create a point-time dump of process statistics
@return [Adhearsion::Statistics::Dump]
# File lib/adhearsion/statistics.rb, line 53 def dump Dump.new timestamp: Time.now, call_counts: dump_call_counts, calls_by_route: dump_calls_by_route end
register_call_dialed()
click to toggle source
@private
# File lib/adhearsion/statistics.rb, line 58 def register_call_dialed @calls_dialed += 1 end
register_call_offered()
click to toggle source
@private
# File lib/adhearsion/statistics.rb, line 63 def register_call_offered @calls_offered += 1 end
register_call_rejected()
click to toggle source
@private
# File lib/adhearsion/statistics.rb, line 74 def register_call_rejected @calls_rejected += 1 end
register_call_routed(data)
click to toggle source
@private
# File lib/adhearsion/statistics.rb, line 68 def register_call_routed(data) @calls_routed += 1 @calls_by_route[data[:route].name] += 1 end
to_s()
click to toggle source
# File lib/adhearsion/statistics.rb, line 78 def to_s "#<#{self.class} dump=#{dump}>" end
Also aliased as: inspect
Private Instance Methods
dump_call_counts()
click to toggle source
# File lib/adhearsion/statistics.rb, line 85 def dump_call_counts {dialed: @calls_dialed, offered: @calls_offered, routed: @calls_routed, rejected: @calls_rejected, active: Adhearsion.active_calls.count} end
dump_calls_by_route()
click to toggle source
# File lib/adhearsion/statistics.rb, line 89 def dump_calls_by_route @calls_by_route.tap do |index| Adhearsion.router.routes.each do |route| index[route.name] end end end