]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11077 refactor log profiling in CeWorkerImpl
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 26 Jul 2018 14:32:18 +0000 (16:32 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 2 Aug 2018 18:21:34 +0000 (20:21 +0200)
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerImpl.java

index 831d040691343b790e66bb82dd6851a282fb4b83..861f1b7c058ab051e3f5e2c39c533f5204822810 100644 (file)
@@ -123,7 +123,7 @@ public class CeWorkerImpl implements CeWorker {
 
   private void executeTask(CeTask task) {
     callListeners(t -> t.onStart(task));
-    Profiler ceProfiler = startActivityProfiler(task);
+    Profiler ceProfiler = startLogProfiler(task);
 
     CeActivityDto.Status status = CeActivityDto.Status.FAILED;
     CeTaskResult taskResult = null;
@@ -173,23 +173,13 @@ public class CeWorkerImpl implements CeWorker {
       }
     } finally {
       // finalize
-      stopActivityProfiler(ceProfiler, task, status);
+      stopLogProfiler(ceProfiler, status);
       callListeners(t -> t.onEnd(task, status, taskResult, error));
     }
   }
 
-  private static Profiler startActivityProfiler(CeTask task) {
+  private static Profiler startLogProfiler(CeTask task) {
     Profiler profiler = Profiler.create(LOG);
-    addContext(profiler, task, null);
-    return profiler.startInfo("Execute task");
-  }
-
-  private static void stopActivityProfiler(Profiler profiler, CeTask task, CeActivityDto.Status status) {
-    addContext(profiler, task, status);
-    profiler.stopInfo("Executed task");
-  }
-
-  private static void addContext(Profiler profiler, CeTask task, @Nullable CeActivityDto.Status status) {
     profiler
       .logTimeLast(true)
       .addContext("project", task.getComponentKey())
@@ -199,8 +189,11 @@ public class CeWorkerImpl implements CeWorker {
     if (submitterLogin != null) {
       profiler.addContext("submitter", submitterLogin);
     }
-    if (status != null) {
-      profiler.addContext("status", status.name());
-    }
+    return profiler.startInfo("Execute task");
+  }
+
+  private static void stopLogProfiler(Profiler profiler, CeActivityDto.Status status) {
+    profiler.addContext("status", status.name());
+    profiler.stopInfo("Executed task");
   }
 }