mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-31 03:14:06 +08:00
补全下 tracer 组件的注释
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
package cn.iocoder.dashboard.framework.tracer.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
|
||||
/**
|
||||
* 打印业务流水号/业务类型注解
|
||||
*
|
||||
* @author 麻薯
|
||||
*/
|
||||
public @interface BizTracing {
|
||||
|
||||
/**
|
||||
* 交易流水tag名
|
||||
*/
|
||||
String BIZ_ID_TAG = "bizId";
|
||||
/**
|
||||
* 交易类型tag名
|
||||
*/
|
||||
String BIZ_TYPE_TAG = "bizType";
|
||||
|
||||
String bizId();
|
||||
|
||||
String bizType();
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.dashboard.framework.tracer.config;
|
||||
|
||||
import cn.iocoder.dashboard.framework.tracer.annotation.BizTracingAop;
|
||||
import cn.iocoder.dashboard.framework.tracer.core.annotation.BizTracingAop;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -9,7 +9,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* BizTracer Bean 配置类
|
||||
* Tracer 配置类
|
||||
*
|
||||
* @author mashu
|
||||
*/
|
||||
@@ -17,8 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConditionalOnClass({BizTracingAop.class})
|
||||
@EnableConfigurationProperties(BizTracerProperties.class)
|
||||
@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true)
|
||||
public class BizTracerAutoConfiguration {
|
||||
|
||||
public class TracerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@@ -27,7 +26,8 @@ public class BizTracerAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BizTracingAop enableBizTracingAop() {
|
||||
@ConditionalOnMissingBean
|
||||
public BizTracingAop bizTracingAop() {
|
||||
return new BizTracingAop();
|
||||
}
|
||||
|
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.dashboard.framework.tracer.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 打印业务编号 / 业务类型注解
|
||||
*
|
||||
* @author 麻薯
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface BizTracing {
|
||||
|
||||
/**
|
||||
* 业务编号 tag 名
|
||||
*/
|
||||
String ID_TAG = "biz.id";
|
||||
/**
|
||||
* 业务类型 tag 名
|
||||
*/
|
||||
String TYPE_TAG = "biz.type";
|
||||
|
||||
/**
|
||||
* @return 业务编号
|
||||
*/
|
||||
String id();
|
||||
|
||||
/**
|
||||
* @return 业务类型
|
||||
*/
|
||||
String type();
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.dashboard.framework.tracer.annotation;
|
||||
package cn.iocoder.dashboard.framework.tracer.core.annotation;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.dashboard.util.sping.SpElUtil;
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
|
||||
/**
|
||||
* 业务链路AOP切面
|
||||
@@ -20,14 +19,14 @@ public class BizTracingAop {
|
||||
|
||||
@Around(value = "@annotation(bizTracing)")
|
||||
public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) {
|
||||
String bizId = (String) SpElUtil.analysisSpEl(bizTracing.bizId(), joinPoint);
|
||||
String bizType = (String) SpElUtil.analysisSpEl(bizTracing.bizType(), joinPoint);
|
||||
String bizId = (String) SpElUtil.analysisSpEl(bizTracing.id(), joinPoint);
|
||||
String bizType = (String) SpElUtil.analysisSpEl(bizTracing.type(), joinPoint);
|
||||
if (StrUtil.isBlankIfStr(bizId)) {
|
||||
log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType);
|
||||
return;
|
||||
}
|
||||
log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType);
|
||||
ActiveSpan.tag(BizTracing.BIZ_ID_TAG, bizId);
|
||||
ActiveSpan.tag(BizTracing.BIZ_TYPE_TAG, bizType);
|
||||
ActiveSpan.tag(BizTracing.ID_TAG, bizId);
|
||||
ActiveSpan.tag(BizTracing.TYPE_TAG, bizType);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user