diff --git a/pom.xml b/pom.xml index f3acf5108..fc89b9800 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 2.2.0 1.7.0 - 8.4.0 + 8.5.0 6.1 2.3.1 diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracing.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracing.java deleted file mode 100644 index 646f5277a..000000000 --- a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracing.java +++ /dev/null @@ -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(); - -} diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/TracerAutoConfiguration.java similarity index 81% rename from src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java rename to src/main/java/cn/iocoder/dashboard/framework/tracer/config/TracerAutoConfiguration.java index b48a9c49b..917bc673c 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/TracerAutoConfiguration.java @@ -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(); } diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracing.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracing.java new file mode 100644 index 000000000..c663ce62d --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracing.java @@ -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(); + +} diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracingAop.java similarity index 76% rename from src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java rename to src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracingAop.java index 3cd1c35fb..8ce87c027 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracingAop.java @@ -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); } }