Class: RServiceBus::StatisticManager
- Inherits:
-
Object
- Object
- RServiceBus::StatisticManager
- Defined in:
- lib/rservicebus/StatisticManager.rb
Overview
Used to collect various run time stats for runtime reporting
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #getForReporting2 ⇒ Object
- #getForReporting9 ⇒ Object
- #inc(key) ⇒ Object
- #incMessageType(className) ⇒ Object
- #incTotalErrored ⇒ Object
- #incTotalProcessed ⇒ Object
- #incTotalPublished ⇒ Object
- #incTotalReply ⇒ Object
- #incTotalSent ⇒ Object
-
#initialize(host) ⇒ StatisticManager
constructor
A new instance of StatisticManager.
- #report ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(host) ⇒ StatisticManager
Returns a new instance of StatisticManager.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rservicebus/StatisticManager.rb', line 8 def initialize( host ) @host = host @hash = Hash.new @totalProcessed = 0 @totalErrored = 0 @totalSent = 0 @totalPublished = 0 @totalReply = 0 @totalByMessageType = Hash.new @output = !RServiceBus.getValue( 'VERBOSE', nil ).nil? @maxStatOutputCountdown = RServiceBus.getValue( 'STAT_OUTPUT_COUNTDOWN', '1').to_i @statOutputCountdown = 0 end |
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/rservicebus/StatisticManager.rb', line 6 def output @output end |
Instance Method Details
#getForReporting2 ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rservicebus/StatisticManager.rb', line 61 def getForReporting2 if @written == false then @written = true types = Hash.new(0) ObjectSpace.each_object do|obj| types[obj.class]+=1 end return types end end |
#getForReporting9 ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rservicebus/StatisticManager.rb', line 73 def getForReporting9 string = "T:#{@totalProcessed};E:#{@totalErrored};S:#{@totalSent};P:#{@totalPublished};R:#{@totalReply}" # if @hash.length > 0 then # @hash.each do |k,v| # string = "#{string};#{k}:#{v}" # end # end return string end |
#inc(key) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/rservicebus/StatisticManager.rb', line 45 def inc( key ) if @hash[key].nil? then @hash[key] = 0 end @hash[key] = @hash[key] + 1 end |
#incMessageType(className) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rservicebus/StatisticManager.rb', line 52 def incMessageType( className ) if @totalByMessageType[className].nil? then @totalByMessageType[className] = 1 else @totalByMessageType[className] = @totalByMessageType[className] + 1 end end |
#incTotalErrored ⇒ Object
29 30 31 |
# File 'lib/rservicebus/StatisticManager.rb', line 29 def incTotalErrored @totalErrored = @totalErrored + 1 end |
#incTotalProcessed ⇒ Object
25 26 27 |
# File 'lib/rservicebus/StatisticManager.rb', line 25 def incTotalProcessed @totalProcessed = @totalProcessed + 1 end |
#incTotalPublished ⇒ Object
37 38 39 |
# File 'lib/rservicebus/StatisticManager.rb', line 37 def incTotalPublished @totalPublished = @totalPublished + 1 end |
#incTotalReply ⇒ Object
41 42 43 |
# File 'lib/rservicebus/StatisticManager.rb', line 41 def incTotalReply @totalReply = @totalReply + 1 end |
#incTotalSent ⇒ Object
33 34 35 |
# File 'lib/rservicebus/StatisticManager.rb', line 33 def incTotalSent @totalSent = @totalSent + 1 end |
#report ⇒ Object
85 86 87 88 89 |
# File 'lib/rservicebus/StatisticManager.rb', line 85 def report if @output then @host.log( self.getForReporting9 ) end end |
#tick ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rservicebus/StatisticManager.rb', line 91 def tick @statOutputCountdown = @statOutputCountdown - 1 if @statOutputCountdown <= 0 then self.report @statOutputCountdown = @maxStatOutputCountdown end end |