Class: RServiceBus::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/rservicebus/Stats.rb

Overview

Used to collect various run time stats for runtime reporting

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns a new instance of Stats.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rservicebus/Stats.rb', line 6

def initialize
	@hash = Hash.new

	@totalProcessed = 0
	@totalErrored = 0
	@totalSent = 0
	@totalPublished = 0
	@totalReply = 0

	@totalByMessageType = Hash.new
       
       @written = false

end

Instance Method Details

#getForReportingObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rservicebus/Stats.rb', line 69

def getForReporting
	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

#getForReporting2Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rservicebus/Stats.rb', line 57

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

#inc(key) ⇒ Object



41
42
43
44
45
46
# File 'lib/rservicebus/Stats.rb', line 41

def inc( key )
	if @hash[key].nil? then
		@hash[key] = 0
	end
	@hash[key] = @hash[key] + 1
end

#incMessageType(className) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/rservicebus/Stats.rb', line 48

def incMessageType( className )
	if @totalByMessageType[className].nil? then
		@totalByMessageType[className] = 1
	else
		@totalByMessageType[className] = @totalByMessageType[className] + 1
	end

end

#incTotalErroredObject



25
26
27
# File 'lib/rservicebus/Stats.rb', line 25

def incTotalErrored
	@totalErrored = @totalErrored + 1
end

#incTotalProcessedObject



21
22
23
# File 'lib/rservicebus/Stats.rb', line 21

def incTotalProcessed
	@totalProcessed = @totalProcessed + 1
end

#incTotalPublishedObject



33
34
35
# File 'lib/rservicebus/Stats.rb', line 33

def incTotalPublished
	@totalPublished = @totalPublished + 1
end

#incTotalReplyObject



37
38
39
# File 'lib/rservicebus/Stats.rb', line 37

def incTotalReply
	@totalReply = @totalReply + 1
end

#incTotalSentObject



29
30
31
# File 'lib/rservicebus/Stats.rb', line 29

def incTotalSent
	@totalSent = @totalSent + 1
end