Forráskód Böngészése

ADD: 监控打印时长

sunxy 1 éve
szülő
commit
035b10a53d

+ 5 - 5
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/framework/recaller/BaseRecaller.java

@@ -151,7 +151,8 @@ public class BaseRecaller<Video> {
      * @return
      */
     public List<RankItem> recalling(final RecommendRequest requestData, final User user, int requestIndex, List<Candidate> recallCandidates) {
-
+        Stopwatch stopwatch = Stopwatch.createStarted();
+        stopwatch.start();
         // load from redis
         List<Callable<Map<Candidate, Queue<Video>>>> fetchQueueCalls = Lists.newArrayList();
         fetchQueueCalls.add(() -> {
@@ -190,11 +191,10 @@ public class BaseRecaller<Video> {
             }
         }
 
-        LOGGER.info("traceId: [{}], recall candidateQueueMap: [{}]", requestData.getRequestId(),
-                JSONObject.toJSONString(candidateQueueMap));
+        LOGGER.info("traceId: [{}], cost = {}, recall candidateQueueMap: [{}]", requestData.getRequestId(),
+                stopwatch.elapsed().toMillis(), JSONObject.toJSONString(candidateQueueMap));
 
-        Stopwatch stopwatch = Stopwatch.createStarted();
-        stopwatch.start();
+        stopwatch.reset().start();
         List<RankItem> result = convertToRankItem(candidateQueueMap, requestData, user);
 
         LOGGER.info("traceId: [{}], cost = {}, convertToRankItem result: [{}]", requestData.getRequestId(),