Commit 81b1f3751ad4c857a0bc8003ae8af37c725a1c0f
1 parent
22a09d07
补全下 tracer 组件的注释
Showing
4 changed files
with
28 additions
and
24 deletions
pom.xml
| @@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
| 38 | <lock4j.version>2.2.0</lock4j.version> | 38 | <lock4j.version>2.2.0</lock4j.version> |
| 39 | <resilience4j.version>1.7.0</resilience4j.version> | 39 | <resilience4j.version>1.7.0</resilience4j.version> |
| 40 | <!-- 监控相关 --> | 40 | <!-- 监控相关 --> |
| 41 | - <skywalking.version>8.4.0</skywalking.version> | 41 | + <skywalking.version>8.5.0</skywalking.version> |
| 42 | <logback.encoder.version>6.1</logback.encoder.version> | 42 | <logback.encoder.version>6.1</logback.encoder.version> |
| 43 | <spring-boot-admin.version>2.3.1</spring-boot-admin.version> | 43 | <spring-boot-admin.version>2.3.1</spring-boot-admin.version> |
| 44 | <!-- 工具类相关 --> | 44 | <!-- 工具类相关 --> |
src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java renamed to src/main/java/cn/iocoder/dashboard/framework/tracer/config/TracerAutoConfiguration.java
| 1 | package cn.iocoder.dashboard.framework.tracer.config; | 1 | package cn.iocoder.dashboard.framework.tracer.config; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.dashboard.framework.tracer.annotation.BizTracingAop; | 3 | +import cn.iocoder.dashboard.framework.tracer.core.annotation.BizTracingAop; |
| 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| @@ -9,7 +9,7 @@ import org.springframework.context.annotation.Bean; | @@ -9,7 +9,7 @@ import org.springframework.context.annotation.Bean; | ||
| 9 | import org.springframework.context.annotation.Configuration; | 9 | import org.springframework.context.annotation.Configuration; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | - * BizTracer Bean 配置类 | 12 | + * Tracer 配置类 |
| 13 | * | 13 | * |
| 14 | * @author mashu | 14 | * @author mashu |
| 15 | */ | 15 | */ |
| @@ -17,8 +17,7 @@ import org.springframework.context.annotation.Configuration; | @@ -17,8 +17,7 @@ import org.springframework.context.annotation.Configuration; | ||
| 17 | @ConditionalOnClass({BizTracingAop.class}) | 17 | @ConditionalOnClass({BizTracingAop.class}) |
| 18 | @EnableConfigurationProperties(BizTracerProperties.class) | 18 | @EnableConfigurationProperties(BizTracerProperties.class) |
| 19 | @ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true) | 19 | @ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true) |
| 20 | -public class BizTracerAutoConfiguration { | ||
| 21 | - | 20 | +public class TracerAutoConfiguration { |
| 22 | 21 | ||
| 23 | @Bean | 22 | @Bean |
| 24 | @ConditionalOnMissingBean | 23 | @ConditionalOnMissingBean |
| @@ -27,7 +26,8 @@ public class BizTracerAutoConfiguration { | @@ -27,7 +26,8 @@ public class BizTracerAutoConfiguration { | ||
| 27 | } | 26 | } |
| 28 | 27 | ||
| 29 | @Bean | 28 | @Bean |
| 30 | - public BizTracingAop enableBizTracingAop() { | 29 | + @ConditionalOnMissingBean |
| 30 | + public BizTracingAop bizTracingAop() { | ||
| 31 | return new BizTracingAop(); | 31 | return new BizTracingAop(); |
| 32 | } | 32 | } |
| 33 | 33 |
src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracing.java renamed to src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracing.java
| 1 | -package cn.iocoder.dashboard.framework.tracer.annotation; | 1 | +package cn.iocoder.dashboard.framework.tracer.core.annotation; |
| 2 | 2 | ||
| 3 | import java.lang.annotation.*; | 3 | import java.lang.annotation.*; |
| 4 | 4 | ||
| 5 | -@Target({ElementType.METHOD}) | ||
| 6 | -@Retention(RetentionPolicy.RUNTIME) | ||
| 7 | -@Inherited | ||
| 8 | - | ||
| 9 | /** | 5 | /** |
| 10 | - * 打印业务流水号/业务类型注解 | 6 | + * 打印业务编号 / 业务类型注解 |
| 11 | * | 7 | * |
| 12 | * @author 麻薯 | 8 | * @author 麻薯 |
| 13 | */ | 9 | */ |
| 10 | +@Target({ElementType.METHOD}) | ||
| 11 | +@Retention(RetentionPolicy.RUNTIME) | ||
| 12 | +@Inherited | ||
| 14 | public @interface BizTracing { | 13 | public @interface BizTracing { |
| 15 | 14 | ||
| 16 | /** | 15 | /** |
| 17 | - * 交易流水tag名 | 16 | + * 业务编号 tag 名 |
| 18 | */ | 17 | */ |
| 19 | - String BIZ_ID_TAG = "bizId"; | 18 | + String ID_TAG = "biz.id"; |
| 20 | /** | 19 | /** |
| 21 | - * 交易类型tag名 | 20 | + * 业务类型 tag 名 |
| 22 | */ | 21 | */ |
| 23 | - String BIZ_TYPE_TAG = "bizType"; | 22 | + String TYPE_TAG = "biz.type"; |
| 24 | 23 | ||
| 25 | - String bizId(); | 24 | + /** |
| 25 | + * @return 业务编号 | ||
| 26 | + */ | ||
| 27 | + String id(); | ||
| 26 | 28 | ||
| 27 | - String bizType(); | 29 | + /** |
| 30 | + * @return 业务类型 | ||
| 31 | + */ | ||
| 32 | + String type(); | ||
| 28 | 33 | ||
| 29 | } | 34 | } |
src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java renamed to src/main/java/cn/iocoder/dashboard/framework/tracer/core/annotation/BizTracingAop.java
| 1 | -package cn.iocoder.dashboard.framework.tracer.annotation; | 1 | +package cn.iocoder.dashboard.framework.tracer.core.annotation; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | import cn.iocoder.dashboard.util.sping.SpElUtil; | 4 | import cn.iocoder.dashboard.util.sping.SpElUtil; |
| @@ -7,7 +7,6 @@ import org.apache.skywalking.apm.toolkit.trace.ActiveSpan; | @@ -7,7 +7,6 @@ import org.apache.skywalking.apm.toolkit.trace.ActiveSpan; | ||
| 7 | import org.aspectj.lang.ProceedingJoinPoint; | 7 | import org.aspectj.lang.ProceedingJoinPoint; |
| 8 | import org.aspectj.lang.annotation.Around; | 8 | import org.aspectj.lang.annotation.Around; |
| 9 | import org.aspectj.lang.annotation.Aspect; | 9 | import org.aspectj.lang.annotation.Aspect; |
| 10 | -import org.springframework.context.annotation.Configuration; | ||
| 11 | 10 | ||
| 12 | /** | 11 | /** |
| 13 | * 业务链路AOP切面 | 12 | * 业务链路AOP切面 |
| @@ -20,14 +19,14 @@ public class BizTracingAop { | @@ -20,14 +19,14 @@ public class BizTracingAop { | ||
| 20 | 19 | ||
| 21 | @Around(value = "@annotation(bizTracing)") | 20 | @Around(value = "@annotation(bizTracing)") |
| 22 | public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) { | 21 | public void tagBizInfo(ProceedingJoinPoint joinPoint, BizTracing bizTracing) { |
| 23 | - String bizId = (String) SpElUtil.analysisSpEl(bizTracing.bizId(), joinPoint); | ||
| 24 | - String bizType = (String) SpElUtil.analysisSpEl(bizTracing.bizType(), joinPoint); | 22 | + String bizId = (String) SpElUtil.analysisSpEl(bizTracing.id(), joinPoint); |
| 23 | + String bizType = (String) SpElUtil.analysisSpEl(bizTracing.type(), joinPoint); | ||
| 25 | if (StrUtil.isBlankIfStr(bizId)) { | 24 | if (StrUtil.isBlankIfStr(bizId)) { |
| 26 | log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType); | 25 | log.error("empty biz: bizId[{}], bizType[{}].", bizId, bizType); |
| 27 | return; | 26 | return; |
| 28 | } | 27 | } |
| 29 | log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType); | 28 | log.info("accept biz: bizId[{}], bizType[{}].", bizId, bizType); |
| 30 | - ActiveSpan.tag(BizTracing.BIZ_ID_TAG, bizId); | ||
| 31 | - ActiveSpan.tag(BizTracing.BIZ_TYPE_TAG, bizType); | 29 | + ActiveSpan.tag(BizTracing.ID_TAG, bizId); |
| 30 | + ActiveSpan.tag(BizTracing.TYPE_TAG, bizType); | ||
| 32 | } | 31 | } |
| 33 | } | 32 | } |