Explorar o código

feat:新增日志上报

zhaohaipeng hai 11 meses
pai
achega
089b13a6b3

+ 1 - 1
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/score/model/ModelManager.java

@@ -202,7 +202,7 @@ public class ModelManager {
             }
             ossObj.close();
         } catch (Exception e) {
-            log.error("update model fail", e);
+            log.error("update model fail: {}", loadTask.path, e);
         } finally {
             loadTask.isLoading = false;
             if (ossObj != null) {

+ 25 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/VideoAdThompsonScorerV2.java

@@ -6,6 +6,7 @@ import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
 import com.tzld.piaoquan.ad.engine.commons.score.ScoreParam;
 import com.tzld.piaoquan.ad.engine.service.score.dto.AdPlatformCreativeDTO;
 import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
+import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.math3.distribution.BetaDistribution;
 import org.slf4j.Logger;
@@ -253,6 +254,9 @@ public class VideoAdThompsonScorerV2 {
         for (AdRankItem adRankItem : result) {
             adRankItem.setVideoId(param.getVideoId());
             adRankItem.setScore_type(699);
+            if (MapUtils.isNotEmpty(adRankItem.getExt())) {
+                adRankItem.getExt().put("abCode", 699);
+            }
         }
 
         return result;
@@ -269,6 +273,9 @@ public class VideoAdThompsonScorerV2 {
         for (AdRankItem adRankItem : result) {
             adRankItem.setVideoId(param.getVideoId());
             adRankItem.setScore_type(670);
+            if (MapUtils.isNotEmpty(adRankItem.getExt())){
+                adRankItem.getExt().put("abCode", 670);
+            }
         }
 
         return result;
@@ -286,13 +293,29 @@ public class VideoAdThompsonScorerV2 {
             double w2 = expParam.getOrDefault("w2", 1d);
             double score = ((w1 * vidCidScore + w2 * cidScore) / (w1 + w2)) * dto.getCpa();
 
-            log.info("669 and 670 calcScore cid: {}, score: {}, w1: {}, w2: {}, cidScore: {}, vidCidScore: {}, cidStatistics: {}, vidCidStatistics: {} ",
-                    dto.getCreativeId(), score, w1, w2, cidScore, vidCidScore, JSON.toJSONString(cidStatistic), JSON.toJSONString(vidCidStatistic));
+
+            // 日志上报扩展参数
+            Map<String, Object> ext = new HashMap<>();
+            ext.put("w1", w1);
+            ext.put("w2", w2);
+            ext.put("cidScore", cidScore);
+            ext.put("vidCidScore", vidCidScore);
+            ext.put("cidA", alpha);
+            ext.put("vidCidA", alpha);
+            ext.put("cidB", cidBeta);
+            ext.put("vidCidB", vidCidBeta);
+            ext.put("cidStatistic", JSON.toJSONString(cidStatistic));
+            ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic));
+            ext.put("cpa", dto.getCpa());
+
+            log.info("svc=699And670Score, score: {}, param: {}", score, JSON.toJSONString(expParam));
+
 
             AdRankItem item = new AdRankItem();
             item.setCpa(dto.getCpa());
             item.setAdId(dto.getCreativeId());
             item.setScore(score);
+            item.setExt(ext);
 
             result.add(item);
         }

+ 8 - 0
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/impl/RankServiceImpl.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.ad.engine.service.score.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.ad.engine.service.predict.helper.NewExpInfoHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
@@ -176,6 +177,13 @@ public class RankServiceImpl implements RankService {
             }else {
                 log.info("svc=pid_log obj={}", JSONObject.toJSONString(object));
             }
+
+            for (AdRankItem adRankItem : rankResult) {
+                adRankItem.getExt().put("userAdFeature", JSON.toJSONString(userAdFeature));
+            }
+            // 日志上报
+            logHubService.scoreLogUpload(param, request.getAdIdList(), rankResult, request, inCvrAdjustingExp ? "cvr_adjusting" : "base_line");
+
             return rankResult.get(0);
         }else {
             //空返回值