diff --git a/README.md b/README.md index c24df2bbf..d43db2a6e 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,6 @@ | 🚀 | 错误码管理 | 系统所有错误码的管理,可在线修改错误提示,无需重启服务 | | | 通知公告 | 系统通知公告信息发布维护 | -计划新增功能: -* 邮件 -* 钉钉、飞书等通知 - ### 基础设施 | | 功能 | 描述 | @@ -63,9 +59,6 @@ | 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 | | 🚀 | 单元测试 |基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 | -计划新增: -* 工作流 - ### 研发工具 | | 功能 | 描述 | diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/package-info.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/package-info.java deleted file mode 100644 index 2fc6be20f..000000000 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.adminserver.framework.sms.core.client; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml index ee8b9b6bc..c72a63b30 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/pom.xml @@ -27,6 +27,12 @@ spring-boot-starter + + + io.opentracing + opentracing-util + + cn.iocoder.boot diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java similarity index 96% rename from yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java rename to yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java index ef1c36374..36f9dec82 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/aliyun/AliyunSmsClientIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.framework.sms.core.client.impl.aliyun; +package cn.iocoder.yudao.framework.sms.core.client.impl.aliyun; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java similarity index 96% rename from yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java rename to yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java index 52b4d671a..47de977cb 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/debug/DebugDingTalkSmsClientIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.framework.sms.core.client.impl.debug; +package cn.iocoder.yudao.framework.sms.core.client.impl.debug; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java similarity index 96% rename from yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java rename to yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java index ed73f9e5b..a23094a88 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.framework.sms.core.client.impl.yunpian; +package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian; import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java index ce1bf8613..6979d8e18 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.tracer.core.aop.BizTraceAspect; import cn.iocoder.yudao.framework.tracer.core.filter.TraceFilter; import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; import io.opentracing.Tracer; +import io.opentracing.util.GlobalTracer; import org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -25,21 +26,22 @@ import org.springframework.context.annotation.Configuration; public class YudaoTracerAutoConfiguration { @Bean - @ConditionalOnMissingBean public TracerProperties bizTracerProperties() { return new TracerProperties(); } @Bean - @ConditionalOnMissingBean public BizTraceAspect bizTracingAop() { return new BizTraceAspect(tracer()); } @Bean - @ConditionalOnMissingBean public Tracer tracer() { - return new SkywalkingTracer(); + // 创建 SkywalkingTracer 对象 + SkywalkingTracer tracer = new SkywalkingTracer(); + // 设置为 GlobalTracer 的追踪器 + GlobalTracer.register(tracer); + return tracer; } /** diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/aop/BizTraceAspect.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/aop/BizTraceAspect.java index e4c6810d1..28d94fd0e 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/aop/BizTraceAspect.java +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/aop/BizTraceAspect.java @@ -4,15 +4,16 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.tracer.core.annotation.BizTrace; import cn.iocoder.yudao.framework.common.util.sping.SpringExpressionUtils; +import cn.iocoder.yudao.framework.tracer.core.util.TracerFrameworkUtils; import io.opentracing.Span; import io.opentracing.Tracer; +import io.opentracing.tag.Tags; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -import javax.annotation.Resource; import java.util.Map; import static java.util.Arrays.asList; @@ -35,10 +36,15 @@ public class BizTraceAspect { public Object around(ProceedingJoinPoint joinPoint, BizTrace trace) throws Throwable { // 创建 span String operationName = getOperationName(joinPoint, trace); - Span span = tracer.buildSpan(operationName).start(); + Span span = tracer.buildSpan(operationName) + .withTag(Tags.COMPONENT.getKey(), "biz") + .startManual(); try { // 执行原有方法 return joinPoint.proceed(); + } catch (Throwable throwable) { + TracerFrameworkUtils.onError(throwable, span); + throw throwable; } finally { // 设置 Span 的 biz 属性 setBizTag(span, joinPoint, trace); diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/util/TracerFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/util/TracerFrameworkUtils.java new file mode 100644 index 000000000..51323e7c2 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/core/util/TracerFrameworkUtils.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.framework.tracer.core.util; + +import io.opentracing.Span; +import io.opentracing.tag.Tags; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; + +/** + * 链路追踪 Util + * + * @author 芋道源码 + */ +public class TracerFrameworkUtils { + + /** + * 将异常记录到 Span 中,参考自 com.aliyuncs.utils.TraceUtils + * + * @param throwable 异常 + * @param span Span + */ + public static void onError(Throwable throwable, Span span) { + Tags.ERROR.set(span, Boolean.TRUE); + if (throwable != null) { + span.log(errorLogs(throwable)); + } + } + + private static Map errorLogs(Throwable throwable) { + Map errorLogs = new HashMap(10); + errorLogs.put("event", Tags.ERROR.getKey()); + errorLogs.put("error.object", throwable); + errorLogs.put("error.kind", throwable.getClass().getName()); + String message = throwable.getCause() != null ? throwable.getCause().getMessage() : throwable.getMessage(); + if (message != null) { + errorLogs.put("message", message); + } + StringWriter sw = new StringWriter(); + throwable.printStackTrace(new PrintWriter(sw)); + errorLogs.put("stack", sw.toString()); + return errorLogs; + } + +} diff --git a/更新日志.md b/更新日志.md new file mode 100644 index 000000000..25417acca --- /dev/null +++ b/更新日志.md @@ -0,0 +1,19 @@ +## 计划中 + +* 邮件 +* 钉钉、飞书等通知 +* 工作流 +* 支付 +* 三方平台接入 + +## [v1.0.0] 2021.05.03 + +### ⭐ New Features + +### ⚡️ Optimization + +### 🐞 Bug Fixes + +### 📔 Documentation + +### 🔨 Dependency Upgrades