aboutsummaryrefslogtreecommitdiff
path: root/lib/longboat/raiders.rb
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-03-16 10:35:52 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-03-16 10:35:52 +0000
commit375adfa8f4ed8d96d9b0e4ab3844fa274f7ff234 (patch)
treedc2fde7fcb96775fc695582f4c0147883cd90ced /lib/longboat/raiders.rb
parent666ea91e473554acabe6f6c3477eb915e70a7538 (diff)
Added automagic longboat_meta_raider_runtime metric
Diffstat (limited to 'lib/longboat/raiders.rb')
-rw-r--r--lib/longboat/raiders.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/longboat/raiders.rb b/lib/longboat/raiders.rb
index 103cac5..e27ac0b 100644
--- a/lib/longboat/raiders.rb
+++ b/lib/longboat/raiders.rb
@@ -2,7 +2,7 @@ module Longboat
class Raiders
def initialize(collector, config)
@collector = collector
- @raiders = []
+ @raiders = {}
@config = config
@config[:raiders_path].each do |dir|
@@ -15,13 +15,26 @@ module Longboat
cname = reqname.split('_').map(&:capitalize).join
require "raiders/#{reqname}"
- @raiders << Kernel.const_get(cname).new(@collector, raider_config)
+ @raiders[reqname] = Kernel.const_get(cname).new(@collector, raider_config)
end
end
end
def raid!
- @raiders.each(&: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}
+ )
+ end
end
def raid_every(time = @config[:raid_every], async = true)