mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
补全下 tracer 组件的注释
This commit is contained in:
parent
22a09d079f
commit
81b1f3751a
2
pom.xml
2
pom.xml
@ -38,7 +38,7 @@
|
|||||||
<lock4j.version>2.2.0</lock4j.version>
|
<lock4j.version>2.2.0</lock4j.version>
|
||||||
<resilience4j.version>1.7.0</resilience4j.version>
|
<resilience4j.version>1.7.0</resilience4j.version>
|
||||||
<!-- 监控相关 -->
|
<!-- 监控相关 -->
|
||||||
<skywalking.version>8.4.0</skywalking.version>
|
<skywalking.version>8.5.0</skywalking.version>
|
||||||
<logback.encoder.version>6.1</logback.encoder.version>
|
<logback.encoder.version>6.1</logback.encoder.version>
|
||||||
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
|
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
|
||||||
<!-- 工具类相关 -->
|
<!-- 工具类相关 -->
|
||||||
|
@ -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;
|
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.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BizTracer Bean 配置类
|
* Tracer 配置类
|
||||||
*
|
*
|
||||||
* @author mashu
|
* @author mashu
|
||||||
*/
|
*/
|
||||||
@ -17,8 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@ConditionalOnClass({BizTracingAop.class})
|
@ConditionalOnClass({BizTracingAop.class})
|
||||||
@EnableConfigurationProperties(BizTracerProperties.class)
|
@EnableConfigurationProperties(BizTracerProperties.class)
|
||||||
@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true)
|
@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true)
|
||||||
public class BizTracerAutoConfiguration {
|
public class TracerAutoConfiguration {
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ -27,7 +26,8 @@ public class BizTracerAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public BizTracingAop enableBizTracingAop() {
|
@ConditionalOnMissingBean
|
||||||
|
public BizTracingAop bizTracingAop() {
|
||||||
return new 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.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.dashboard.util.sping.SpElUtil;
|
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.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务链路AOP切面
|
* 业务链路AOP切面
|
||||||
@ -20,14 +19,14 @@ public class BizTracingAop {
|
|||||||
|
|
||||||
@Around(value = "@annotation(bizTracing)")
|
@Around(value = "@annotation(bizTracing)")
|
||||||
public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) {
|
public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) {
|
||||||
String bizId = (String) SpElUtil.analysisSpEl(bizTracing.bizId(), joinPoint);
|
String bizId = (String) SpElUtil.analysisSpEl(bizTracing.id(), joinPoint);
|
||||||
String bizType = (String) SpElUtil.analysisSpEl(bizTracing.bizType(), joinPoint);
|
String bizType = (String) SpElUtil.analysisSpEl(bizTracing.type(), joinPoint);
|
||||||
if (StrUtil.isBlankIfStr(bizId)) {
|
if (StrUtil.isBlankIfStr(bizId)) {
|
||||||
log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType);
|
log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType);
|
log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType);
|
||||||
ActiveSpan.tag(BizTracing.BIZ_ID_TAG, bizId);
|
ActiveSpan.tag(BizTracing.ID_TAG, bizId);
|
||||||
ActiveSpan.tag(BizTracing.BIZ_TYPE_TAG, bizType);
|
ActiveSpan.tag(BizTracing.TYPE_TAG, bizType);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user