Commit 7f84e44e94d79cc33a109cbd415c981886bf3b73

Authored by dark
1 parent fe956b71

交易链路流水号为空时打印错误日志,且不记录链路至skywalking

src/main/java/cn/iocoder/dashboard/common/annotation/BizTracing.java
... ... @@ -13,11 +13,11 @@ import java.lang.annotation.*;
13 13 */
14 14 public @interface BizTracing {
15 15  
16   - String BIZ_ID = "bizId";
17   - String BIZ_TYPE = "bizType";
  16 + String BIZ_ID_TAG = "bizId";
  17 + String BIZ_TYPE_TAG = "bizType";
18 18  
19   - String bizId() default "NULL_ID";
  19 + String bizId();
20 20  
21   - String bizType() default "NULL_TYPE";
  21 + String bizType();
22 22  
23 23 }
... ...
src/main/java/cn/iocoder/dashboard/common/annotation/BizTracingAop.java
1 1 package cn.iocoder.dashboard.common.annotation;
2 2  
  3 +import cn.hutool.core.util.StrUtil;
3 4 import cn.iocoder.dashboard.util.sping.SpElUtil;
4 5 import lombok.extern.slf4j.Slf4j;
5 6 import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
... ... @@ -22,8 +23,12 @@ public class BizTracingAop {
22 23 public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) {
23 24 String bizId = SpElUtil.analysisSpEl(bizTracing.bizId(), joinPoint);
24 25 String bizType = SpElUtil.analysisSpEl(bizTracing.bizType(), joinPoint);
  26 + if (StrUtil.isBlankIfStr(bizId)) {
  27 + log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType);
  28 + return;
  29 + }
25 30 log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType);
26   - ActiveSpan.tag(BizTracing.BIZ_ID, bizId);
27   - ActiveSpan.tag(BizTracing.BIZ_TYPE, bizType);
  31 + ActiveSpan.tag(BizTracing.BIZ_ID_TAG, bizId);
  32 + ActiveSpan.tag(BizTracing.BIZ_TYPE_TAG, bizType);
28 33 }
29 34 }
... ...