<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/deep_test/metrics/data.rb</filename>
    </added>
    <added>
      <filename>lib/deep_test/metrics/measurement.rb</filename>
    </added>
    <added>
      <filename>test/deep_test/metrics/data_test.rb</filename>
    </added>
    <added>
      <filename>test/deep_test/metrics/measurement_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,4 +2,5 @@ deep_test.metrics
 doc
 pkg
 tags
+negative_acceptance_tests/metrics.data
 </diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -34,7 +34,6 @@ end
 
 DeepTest::TestTask.new :deep_test do |t|
   t.pattern = &quot;test/**/*_test.rb&quot;
-  t.metrics_file = &quot;deep_test.metrics&quot;
 end
 
 DeepTest::TestTask.new(:manual_distributed_test) do |t|</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -65,6 +65,9 @@ require File.dirname(__FILE__) + &quot;/deep_test/distributed/remote_deployment&quot;
 require File.dirname(__FILE__) + &quot;/deep_test/distributed/beachhead&quot;
 require File.dirname(__FILE__) + &quot;/deep_test/distributed/rsync&quot;
 
+require File.dirname(__FILE__) + &quot;/deep_test/metrics/data&quot;
+require File.dirname(__FILE__) + &quot;/deep_test/metrics/measurement&quot;
+
 DeepTest::RSpecDetector.if_rspec_available do
   require File.dirname(__FILE__) + &quot;/deep_test/spec&quot;
 end</diff>
      <filename>lib/deep_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,7 +31,9 @@ module DeepTest
         @listener.starting_work(self, work_unit_message.body)
 
         result = begin
-                   work_unit_message.body.run
+                   Metrics::Measurement.send_home(&quot;Agents Performing Work&quot;, @wire, @options) do
+                     work_unit_message.body.run
+                   end
                  rescue Exception =&gt; error
                    Error.new(work_unit_message.body, error)
                  end
@@ -44,15 +46,17 @@ module DeepTest
     end
 
     def next_work_unit_message
-      begin
-        message = @wire.next_message(:timeout =&gt; 2)
-        return message.body == CentralCommand::NoMoreWork ? nil : message
-      rescue Telegraph::NoMessageAvailable
-        DeepTest.logger.debug { &quot;Agent: NoMessageAvailable&quot; }
-        retry
-      rescue Telegraph::LineDead
-        DeepTest.logger.debug { &quot;Agent: LineDead&quot; }
-        return nil
+      Metrics::Measurement.send_home(&quot;Agents Retrieving Work&quot;, @wire, @options) do
+        begin
+          message = @wire.next_message(:timeout =&gt; 2)
+          next message.body == CentralCommand::NoMoreWork ? nil : message
+        rescue Telegraph::NoMessageAvailable
+          DeepTest.logger.debug { &quot;Agent: NoMessageAvailable&quot; }
+          retry
+        rescue Telegraph::LineDead
+          DeepTest.logger.debug { &quot;Agent: LineDead&quot; }
+          next nil
+        end
       end
     end
 </diff>
      <filename>lib/deep_test/agent.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ module DeepTest
   class CentralCommand
     attr_reader :operator
     attr_reader :switchboard
+    attr_reader :data
 
     def initialize(options)
       @options = options
@@ -11,6 +12,7 @@ module DeepTest
       @results_mutex = Mutex.new
       @results_condvar = ConditionVariable.new
       @results = []
+      @data = Metrics::Data.new
     end
 
     def done_with_work
@@ -103,6 +105,8 @@ module DeepTest
             send_work wire
           when Operation
             message.body.execute
+          when Metrics::Measurement
+            data.add message.body
           else 
             raise UnexpectedMessageError, message.inspect
           end
@@ -149,6 +153,7 @@ module DeepTest
       @stop_process_messages = true
       operator.shutdown
       @process_messages_thread.join
+      data.save @options.metrics_file if @options.gathering_metrics?
     end
 
     class NoWorkUnitsAvailableError &lt; StandardError; end</diff>
      <filename>lib/deep_test/central_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,11 @@ DeepTest::TestTask.new :deep_test_with_work_taken_and_not_done do |t|
   t.pattern = &quot;negative_acceptance_tests/passing_test.rb&quot;
 end
 
+DeepTest::TestTask.new :deep_test_with_metrics do |t|
+  t.pattern = &quot;negative_acceptance_tests/passing_test.rb&quot;
+  t.metrics_file = &quot;negative_acceptance_tests/metrics.data&quot;
+end
+
 Spec::Rake::SpecTask.new :deep_spec_failing do |t|
   t.deep_test :number_of_agents =&gt; 1
   t.spec_files = FileList[&quot;negative_acceptance_tests/failing_spec.rb&quot;]
@@ -75,3 +80,8 @@ Spec::Rake::SpecTask.new :deep_spec_with_work_taken_and_not_done do |t|
                           &quot;negative_acceptance_tests/passing_test.rb&quot;]
   t.deep_test :number_of_agents =&gt; 2, :listener =&gt; &quot;KillAgentOneOnStartWork&quot;
 end
+
+Spec::Rake::SpecTask.new :deep_spec_with_metrics do |t|
+  t.deep_test :number_of_agents =&gt; 1, :metrics_file =&gt; &quot;negative_acceptance_tests/metrics.data&quot;
+  t.spec_files = FileList[&quot;negative_acceptance_tests/passing_spec.rb&quot;]
+end</diff>
      <filename>negative_acceptance_tests/tasks.rake</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,17 @@ unit_tests do
 
     test &quot;#{framework}: DeepTest with work taken and not done&quot; do
       result, output = run_rake framework, :with_work_taken_and_not_done 
-      assert_equal true, result.success?
+      assert_equal true, result.success?, output
+    end
+
+    test &quot;#{framework}: DeepTest with metrics&quot; do
+      FileUtils.rm_f &quot;negative_acceptance_tests/metrics.data&quot;
+      result, output = run_rake framework, :with_metrics
+      assert_equal true, result.success?, output
+      metrics = File.read(&quot;negative_acceptance_tests/metrics.data&quot;)
+      assert_match /Metrics Data/, metrics
+      assert_match /Agents Performing Work:/, metrics
+      assert_match /Agents Retrieving Work:/, metrics
     end
   end
 </diff>
      <filename>negative_acceptance_tests/tests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -93,7 +93,7 @@ module DeepTest
       assert_equal TestResult.new(1), central_command.take_result
     end
 
-    test &quot;will distributed work units that have not received results from dead workers when other work runs out&quot; do
+    test &quot;will distribute work units that have not received results from dead workers when other work runs out&quot; do
       central_command = CentralCommand.start(options = Options.new({}))
       DynamicTeardown.on_teardown { central_command.stop }
 
@@ -110,6 +110,19 @@ module DeepTest
       end
     end
 
+    test &quot;will add measurements to data when received over the wire&quot; do
+      central_command = CentralCommand.start(options = Options.new({}))
+      DynamicTeardown.on_teardown { central_command.stop }
+
+      Telegraph::Wire.connect(&quot;localhost&quot;, options.server_port) do |wire|
+        wire.send_message Metrics::Measurement.new(&quot;category&quot;, 1, &quot;units&quot;)
+      end
+
+      sleep 0.05
+
+      assert_match /category: 1.0 avg/, central_command.data.summary
+    end
+
     class SetCalledGlobalToTrue
       include CentralCommand::Operation
       def execute; $called = true; end</diff>
      <filename>test/deep_test/central_command_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>be69a521b54b8b8dab60c76e54928a5f7c7fff34</id>
    </parent>
  </parents>
  <author>
    <name>qxjit (David Vollbracht)</name>
    <email>david.vollbracht@gmail.com</email>
  </author>
  <url>http://github.com/qxjit/deep-test/commit/694b08637be87617778116b8570d514224893313</url>
  <id>694b08637be87617778116b8570d514224893313</id>
  <committed-date>2009-07-31T20:38:25-07:00</committed-date>
  <authored-date>2009-07-31T20:38:25-07:00</authored-date>
  <message>add metrics gathering around workers doing working and retrieving work</message>
  <tree>920e7e7ec5d93eaee26d265df257d77875fc2bbd</tree>
  <committer>
    <name>qxjit (David Vollbracht)</name>
    <email>david.vollbracht@gmail.com</email>
  </committer>
</commit>
