Object
Caches perfs and faults. If either has been seen before update their respective counts. This is used by the mole to track if a perf or exception was previously recorded.
# File lib/rackamole/stash/collector.rb, line 11
11: def initialize( app_name, environment, expiration=24*60*60 )
12: @expiration = expiration
13: @app_id = app_name + "_" + environment.to_s
14: @faults = {}
15: @perfs = {}
16: end
Remove all entries that have expired
# File lib/rackamole/stash/collector.rb, line 19
19: def expire!
20: expire_faults!
21: expire_perfs!
22: end
Delete all faults older than expiration
# File lib/rackamole/stash/collector.rb, line 25
25: def expire_faults!
26: now = Time.now
27: faults.each_pair do |stack, fault|
28: if (now - fault.timestamp) >= expiration
29: faults.delete( stack )
30: end
31: end
32: end
Delete all perfs older than expiration
# File lib/rackamole/stash/collector.rb, line 35
35: def expire_perfs!
36: now = Time.now.utc
37: perfs.each_pair do |path, perf|
38: if (now - perf.timestamp) >= expiration
39: perfs.delete( path )
40: end
41: end
42: end
Log or update fault if found... Returns true if updated or false if created
# File lib/rackamole/stash/collector.rb, line 46
46: def stash_fault( path, stack, timestamp )
47: fault = find_fault( path, stack )
48: if fault
49: fault.update( timestamp )
50: return true
51: end
52: fault = create_fault( path, stack, timestamp )
53: faults[stack] = fault
54: false
55: end
Log or update performance issue if found... Returns true if updated or false if created
# File lib/rackamole/stash/collector.rb, line 59
59: def stash_perf( path, elapsed, timestamp )
60: perf = find_perf( path )
61: if perf
62: perf.update( timestamp )
63: return true
64: end
65: perf = create_perf( path, elapsed, timestamp )
66: perfs[path] = perf
67: false
68: end
# File lib/rackamole/stash/collector.rb, line 75
75: def create_fault( path, stack, timestamp )
76: faults[stack] = Rackamole::Stash::Fault.new( path, stack, timestamp )
77: end
# File lib/rackamole/stash/collector.rb, line 79
79: def create_perf( path, elapsed, timestamp )
80: perfs[path] = Rackamole::Stash::Perf.new( path, elapsed, timestamp )
81: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.