]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Log slow linters using service call
authorFrançois Deliège <fdeliege@fb.com>
Tue, 5 Feb 2013 01:25:37 +0000 (17:25 -0800)
committerFrançois Deliège <fdeliege@fb.com>
Wed, 20 Feb 2013 19:43:51 +0000 (11:43 -0800)
Summary:
Following @epriestley suggestion to use PhutilServiceProfiler to log lint as a service call

Test Plan: arc lint

Reviewers: vrana

CC: phunt, aran, epriestley
Differential Revision: https://secure.phabricator.com/D4820

src/__phutil_library_map__.php
src/lint/engine/ArcanistLintEngine.php

index f59aea5c6e3024b19d35fda1fa405ad5fbfa2490..9ea568eb4d9b586bd6146f679b6092f3f299e821 100644 (file)
@@ -161,6 +161,7 @@ phutil_register_library_map(array(
     'PhutilLintEngine' => 'lint/engine/PhutilLintEngine.php',
     'PhutilUnitTestEngine' => 'unit/engine/PhutilUnitTestEngine.php',
     'PhutilUnitTestEngineTestCase' => 'unit/engine/__tests__/PhutilUnitTestEngineTestCase.php',
+    'TimerEventType' => 'events/constant/TimerEventType.php',
     'UnitTestableArcanistLintEngine' => 'lint/engine/UnitTestableArcanistLintEngine.php',
   ),
   'function' =>
@@ -288,6 +289,7 @@ phutil_register_library_map(array(
     'PhutilLintEngine' => 'ArcanistLintEngine',
     'PhutilUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
     'PhutilUnitTestEngineTestCase' => 'ArcanistTestCase',
+    'TimerEventType' => 'PhutilEventType',
     'UnitTestableArcanistLintEngine' => 'ArcanistLintEngine',
   ),
 ));
index 9ea1ddca5b55fff51a88855d86ee0039cf4f66dd..9e99e13aa136ed5ff22635f1e60fe1b4f1afa327 100644 (file)
@@ -230,9 +230,21 @@ abstract class ArcanistLintEngine {
 
         if ($paths) {
           $linter->willLintPaths($paths);
+          $profiler = PhutilServiceProfiler::getInstance();
           foreach ($paths as $path) {
             $linter->willLintPath($path);
-            $linter->lintPath($path);
+            $call_id = $profiler->beginServiceCall(array(
+              'type' => 'lint',
+              'linter' => get_class($linter),
+              'path' => $path,
+              ));
+            try {
+              $linter->lintPath($path);
+            } catch (Exception $ex) {
+              $profiler->endServiceCall($call_id, array());
+              throw $ex;
+            }
+            $profiler->endServiceCall($call_id, array());
             if ($linter->didStopAllLinters()) {
               $this->stopped[$path] = $linter_name;
             }