2021-03-06 22:29:11 +08:00
|
|
|
package cn.iocoder.dashboard.common.annotation;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.dashboard.util.sping.SpElUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.skywalking.apm.toolkit.trace.ActiveSpan;
|
|
|
|
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
|
|
import org.aspectj.lang.annotation.Around;
|
|
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
2021-03-06 22:55:28 +08:00
|
|
|
/**
|
|
|
|
|
* 业务链路AOP切面
|
|
|
|
|
*
|
|
|
|
|
* @author mashu
|
|
|
|
|
*/
|
2021-03-06 22:29:11 +08:00
|
|
|
@Aspect
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Configuration
|
|
|
|
|
public class BizTracingAop {
|
|
|
|
|
|
|
|
|
|
@Around(value = "@annotation(bizTracing)")
|
2021-03-06 22:55:28 +08:00
|
|
|
public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) {
|
2021-03-06 22:29:11 +08:00
|
|
|
String bizId = SpElUtil.analysisSpEl(bizTracing.bizId(), joinPoint);
|
|
|
|
|
String bizType = SpElUtil.analysisSpEl(bizTracing.bizType(), joinPoint);
|
|
|
|
|
log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType);
|
|
|
|
|
ActiveSpan.tag(BizTracing.BIZ_ID, bizId);
|
|
|
|
|
ActiveSpan.tag(BizTracing.BIZ_TYPE, bizType);
|
|
|
|
|
}
|
|
|
|
|
}
|