summaryrefslogtreecommitdiff
path: root/lib/custodian/worker.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-01-24 11:52:29 +0000
committerSteve Kemp <steve@steve.org.uk>2013-01-24 11:52:29 +0000
commit5ae1e6944143acaf6cdc755b7178af827c5913c2 (patch)
tree082463f25056025b4c91ca3d5085cffda085113d /lib/custodian/worker.rb
parent306df261909ea6e0988e95886c566f51ed059030 (diff)
Updated to log duration of test-runs with our alerters, if they
implement a "duration" method.
Diffstat (limited to 'lib/custodian/worker.rb')
-rw-r--r--lib/custodian/worker.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index 11aa0e6..5219a5b 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -160,7 +160,7 @@ module Custodian
#
test = Custodian::TestFactory.create( body )
-
+ start_time = Time.now
#
# We'll run no more than MAX times.
@@ -186,6 +186,20 @@ module Custodian
end
#
+ # End time
+ #
+ end_time = Time.now
+
+
+ #
+ # Duration of the test-run, in milliseconds
+ #
+ duration = (( end_time - start_time ) * 1000.0).to_i
+
+ do_duration( test, duration )
+
+
+ #
# If we didn't succeed on any of the attempts raise the alert.
#
if ( ! result )
@@ -254,6 +268,24 @@ module Custodian
end
end
+ #
+ # Log a test duration with each registered alerter.
+ #
+ def do_duration( test, duration )
+ @alerter.split( "," ).each do |alerter|
+ log_message( "Creating alerter: #{alerter}" )
+ alert = Custodian::AlertFactory.create( alerter, test )
+
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
+ puts "Target for alert is #{target}"
+
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
+ alert.duration( duration ) if ( alert.respond_to? "duration" )
+ end
+ end
#