diff options
author | Nat Lasseter <nat.lasseter@york.ac.uk> | 2020-06-25 13:16:56 +0100 |
---|---|---|
committer | Nat Lasseter <nat.lasseter@york.ac.uk> | 2020-06-25 13:16:56 +0100 |
commit | 5020bfd6cabb588dd34ff4171acac42c9b0e1945 (patch) | |
tree | 80e3d59e0aeb896d7fb45bb83200251793f97b10 /lib/longboat/raiders.rb | |
parent | 8872aaaea63ba2e58c8cd3ee739972e7f8903288 (diff) |
Added transactions to the collector so we can support exception handling on the raiders
Diffstat (limited to 'lib/longboat/raiders.rb')
-rw-r--r-- | lib/longboat/raiders.rb | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/longboat/raiders.rb b/lib/longboat/raiders.rb index 3e6f246..2740570 100644 --- a/lib/longboat/raiders.rb +++ b/lib/longboat/raiders.rb @@ -21,19 +21,28 @@ module Longboat end def raid! + puts "RAID" @raiders.each do |name, raider| - start_time = Time.now - raider.raid - end_time = Time.now - time_taken = end_time - start_time - - @collector.report!( - "longboat_meta_raider_runtime", - (time_taken.to_f * 1000).to_i, - help: "Time taken by a raider whilst raiding in ms", - type: "guage", - labels: {raider: name} - ) + @collector.begin! + + begin + start_time = Time.now + raider.raid + end_time = Time.now + time_taken = end_time - start_time + + @collector.report!( + "longboat_meta_raider_runtime", + (time_taken.to_f * 1000).to_i, + help: "Time taken by a raider whilst raiding in ms", + type: "guage", + labels: {raider: name} + ) + + @collector.commit! + rescue Exception => e + @collector.abort! + end end end |