]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5793 Use TimeProfiler for logs to have duration in compute engine
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 30 Oct 2014 19:35:06 +0000 (20:35 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 30 Oct 2014 20:19:32 +0000 (21:19 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/ComputationService.java

index 9069f9d63f2ca2c1835faee5729b40d31a52a5db..b49f2dce617721fc0a8cc692e0ae3f2094be424d 100644 (file)
@@ -25,6 +25,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.System2;
+import org.sonar.api.utils.TimeProfiler;
 import org.sonar.core.activity.Activity;
 import org.sonar.core.component.ComponentDto;
 import org.sonar.core.computation.db.AnalysisReportDto;
@@ -54,7 +55,7 @@ public class ComputationService implements ServerComponent {
   }
 
   public void analyzeReport(AnalysisReportDto report) {
-    LOG.info(String.format("#%s - %s - Analysis report processing started", report.getId(), report.getProjectKey()));
+    TimeProfiler profiler = new TimeProfiler(LOG).start(String.format("#%s - %s - Analysis report processing", report.getId(), report.getProjectKey()));
 
     // Synchronization of a lot of data can only be done with a batch session for the moment
     DbSession session = dbClient.openSession(true);
@@ -64,10 +65,10 @@ public class ComputationService implements ServerComponent {
     try {
       report.succeed();
       for (ComputationStep step : stepRegistry.steps()) {
-        LOG.info(String.format("%s step started", step.description()));
+        TimeProfiler stepProfiler = new TimeProfiler(LOG).start(step.description());
         step.execute(session, report, project);
         session.commit();
-        LOG.info(String.format("%s step finished", step.description()));
+        stepProfiler.stop();
       }
 
     } catch (Exception exception) {
@@ -77,7 +78,7 @@ public class ComputationService implements ServerComponent {
       logActivity(session, report, project);
       session.commit();
       MyBatis.closeQuietly(session);
-      LOG.info(String.format("#%s - %s - Analysis report processing finished", report.getId(), report.getProjectKey()));
+      profiler.stop();
     }
   }