]> source.dussan.org Git - sonarqube.git/commitdiff
Add logs to ease profiling of preview mode when downloading previous source code
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 10 Sep 2014 14:22:08 +0000 (16:22 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Wed, 10 Sep 2014 20:32:02 +0000 (22:32 +0200)
sonar-batch/src/main/java/org/sonar/batch/scan/LastSnapshots.java

index b36d4dc68523d777aa0aff3322141f3fa703ce54..f3917d40f20b55da965e8c0138bb2c2852c25d73 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch.scan;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.database.model.ResourceModel;
@@ -27,6 +29,7 @@ import org.sonar.api.database.model.SnapshotSource;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.resources.ResourceUtils;
 import org.sonar.api.utils.HttpDownloader;
+import org.sonar.api.utils.TimeProfiler;
 import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.bootstrap.ServerClient;
 
@@ -34,6 +37,8 @@ import javax.persistence.Query;
 
 public class LastSnapshots implements BatchComponent {
 
+  private static final Logger LOG = LoggerFactory.getLogger(LastSnapshots.class);
+
   private final AnalysisMode analysisMode;
   private final DatabaseSession session;
   private final ServerClient server;
@@ -57,6 +62,7 @@ public class LastSnapshots implements BatchComponent {
   }
 
   private String loadSourceFromWs(Resource resource) {
+    TimeProfiler profiler = new TimeProfiler(LOG).start("Load previous source code of: " + resource.getEffectiveKey()).setLevelToDebug();
     try {
       return server.request("/api/sources?resource=" + resource.getEffectiveKey() + "&format=txt", false, analysisMode.getPreviewReadTimeoutSec() * 1000);
     } catch (HttpDownloader.HttpException he) {
@@ -64,6 +70,8 @@ public class LastSnapshots implements BatchComponent {
         return "";
       }
       throw he;
+    } finally {
+      profiler.stop();
     }
   }