diff --git a/cash-api/account-server/src/main/resources/application.yml b/cash-api/account-server/src/main/resources/application.yml index 7cd6922c..f115ca7f 100644 --- a/cash-api/account-server/src/main/resources/application.yml +++ b/cash-api/account-server/src/main/resources/application.yml @@ -8,6 +8,17 @@ spring: active: dev include: tools +# TraceID +management: + tracing: + enabled: true + sampling: + probability: 1.0 # 100% 采样,生产可降低 + zipkin: + tracing: + endpoint: http://192.168.1.42:9411/api/v2/spans + + logging: config: classpath:logback.xml diff --git a/cash-api/account-server/src/main/resources/logback.xml b/cash-api/account-server/src/main/resources/logback.xml index 9637e200..4aafbc96 100644 --- a/cash-api/account-server/src/main/resources/logback.xml +++ b/cash-api/account-server/src/main/resources/logback.xml @@ -2,9 +2,10 @@ account-server - + - + diff --git a/cash-api/market-server/src/main/resources/application.yml b/cash-api/market-server/src/main/resources/application.yml index 02fbb7de..0e227649 100644 --- a/cash-api/market-server/src/main/resources/application.yml +++ b/cash-api/market-server/src/main/resources/application.yml @@ -14,6 +14,17 @@ wx: operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0 +# TraceID +management: + tracing: + enabled: true + sampling: + probability: 1.0 # 100% 采样,生产可降低 + zipkin: + tracing: + endpoint: http://192.168.1.42:9411/api/v2/spans + + logging: config: classpath:logback.xml diff --git a/cash-api/market-server/src/main/resources/logback.xml b/cash-api/market-server/src/main/resources/logback.xml index 090e157b..0e16e6fa 100644 --- a/cash-api/market-server/src/main/resources/logback.xml +++ b/cash-api/market-server/src/main/resources/logback.xml @@ -2,9 +2,10 @@ market-server - + - + diff --git a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java index 949853a9..70d0374b 100644 --- a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java +++ b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java @@ -57,7 +57,7 @@ public class NotifyController { @GetMapping("testOpen") public JSONObject test1(String code) throws Exception { - distributionUserService.distribute(54659L, "WX1983728389726539776", BigDecimal.valueOf(1), 474L, 122L, "order"); + distributionUserService.distribute(54664L, "WX1983735285514747904", BigDecimal.valueOf(1), 474L, 122L, "order"); return null; } diff --git a/cash-api/order-server/src/main/resources/application.yml b/cash-api/order-server/src/main/resources/application.yml index aad8910e..fd46ecbe 100644 --- a/cash-api/order-server/src/main/resources/application.yml +++ b/cash-api/order-server/src/main/resources/application.yml @@ -8,6 +8,17 @@ spring: active: dev include: tools +# TraceID +management: + tracing: + enabled: true + sampling: + probability: 1.0 # 100% 采样,生产可降低 + zipkin: + tracing: + endpoint: http://192.168.1.42:9411/api/v2/spans + + logging: config: classpath:logback.xml diff --git a/cash-api/order-server/src/main/resources/logback.xml b/cash-api/order-server/src/main/resources/logback.xml index 3efadaca..54bda376 100644 --- a/cash-api/order-server/src/main/resources/logback.xml +++ b/cash-api/order-server/src/main/resources/logback.xml @@ -2,9 +2,10 @@ order-server - + - + diff --git a/cash-api/product-server/src/main/resources/application.yml b/cash-api/product-server/src/main/resources/application.yml index b1e26567..93d72653 100644 --- a/cash-api/product-server/src/main/resources/application.yml +++ b/cash-api/product-server/src/main/resources/application.yml @@ -18,6 +18,17 @@ wx: appId: wx1fb600d0f5ea6279 secrete: b4c0534c9b5e6c84a7fe5c2078dff876 +# TraceID +management: + tracing: + enabled: true + sampling: + probability: 1.0 # 100% 采样,生产可降低 + zipkin: + tracing: + endpoint: http://192.168.1.42:9411/api/v2/spans + + logging: config: classpath:logback.xml diff --git a/cash-api/product-server/src/main/resources/logback.xml b/cash-api/product-server/src/main/resources/logback.xml index 7c962d6e..e4418570 100644 --- a/cash-api/product-server/src/main/resources/logback.xml +++ b/cash-api/product-server/src/main/resources/logback.xml @@ -2,9 +2,10 @@ product-server - + - + diff --git a/cash-api/system-server/src/main/resources/application.yml b/cash-api/system-server/src/main/resources/application.yml index 414d20b9..57478e32 100644 --- a/cash-api/system-server/src/main/resources/application.yml +++ b/cash-api/system-server/src/main/resources/application.yml @@ -7,6 +7,17 @@ spring: profiles: active: dev +# TraceID +management: + tracing: + enabled: true + sampling: + probability: 1.0 # 100% 采样,生产可降低 + zipkin: + tracing: + endpoint: http://192.168.1.42:9411/api/v2/spans + + logging: config: classpath:logback.xml diff --git a/cash-api/system-server/src/main/resources/logback.xml b/cash-api/system-server/src/main/resources/logback.xml index 5a70fc3a..da472f62 100644 --- a/cash-api/system-server/src/main/resources/logback.xml +++ b/cash-api/system-server/src/main/resources/logback.xml @@ -2,9 +2,11 @@ system-server - + + - + diff --git a/cash-common/cash-common-api-config/src/main/java/com/czg/aspect/ControllerAspect.java b/cash-common/cash-common-api-config/src/main/java/com/czg/aspect/ControllerAspect.java index f38adf0c..32762f8e 100644 --- a/cash-common/cash-common-api-config/src/main/java/com/czg/aspect/ControllerAspect.java +++ b/cash-common/cash-common-api-config/src/main/java/com/czg/aspect/ControllerAspect.java @@ -11,10 +11,13 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; +import org.slf4j.MDC; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; +import java.util.Map; + /** * 方法调用统一切面处理 @@ -59,7 +62,13 @@ public class ControllerAspect { String requestUrl = request.getRequestURL().toString(); String requestIp = ServletUtil.getClientIP(request); long useTime = end - start; + + Map contextMap = MDC.getCopyOfContextMap(); ThreadUtil.execAsync(() -> { + if (contextMap != null) { + MDC.setContextMap(contextMap); + } + //请求的参数 String resultJson = JSONObject.toJSONString(result); if (StrUtil.isNotBlank(resultJson) && resultJson.length() > 200) { @@ -82,6 +91,8 @@ public class ControllerAspect { } } catch (Exception e) { log.error("Request 为空" + e.getMessage()); + } finally { + MDC.clear(); } }); return result; diff --git a/cash-dependencies/pom.xml b/cash-dependencies/pom.xml index 818ad28a..67c2b1f2 100644 --- a/cash-dependencies/pom.xml +++ b/cash-dependencies/pom.xml @@ -41,6 +41,9 @@ 3.8.0 2.5.1 2.9.10 + 1.6.0-M3 + 3.5.1 + 4.0.0-M3 @@ -242,6 +245,28 @@ excel-spring-boot-starter 3.4.0 + + + + + io.micrometer + micrometer-tracing-bridge-brave + ${micrometer.version} + + + + + io.zipkin.reporter2 + zipkin-reporter-brave + ${zipkin-reporter.version} + + + + org.springframework.boot + spring-boot-starter-actuator + ${actuator.version} + + diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionAmountFlowServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionAmountFlowServiceImpl.java index d4d5de2d..3820d1bd 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionAmountFlowServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionAmountFlowServiceImpl.java @@ -57,7 +57,7 @@ public class MkDistributionAmountFlowServiceImpl extends ServiceImpl pageInfo = pageAs(PageUtil.buildPage(), queryWrapper, MkDistributionAmountFlowVO.class); + Page pageInfo = pageAs(PageUtil.buildPage(), queryWrapper.orderBy(MkDistributionAmountFlow::getCreateTime, false), MkDistributionAmountFlowVO.class); Map map = BeanUtil.beanToMap(pageInfo); map.put("totalRecharge", getOne(new QueryWrapper().eq(MkDistributionAmountFlow::getShopId, shopId) .in(MkDistributionAmountFlow::getType, TableValueConstant.DistributionAmountFlow.Type.MANUAL_RECHARGE.getCode(), TableValueConstant.DistributionAmountFlow.Type.SELF_RECHARGE.getCode()) @@ -100,7 +100,7 @@ public class MkDistributionAmountFlowServiceImpl extends ServiceImpl pageInfo = pageAs(PageUtil.buildPage(), queryWrapper, MkDistributionAmountFlowVO.class); + Page pageInfo = pageAs(PageUtil.buildPage(), queryWrapper.orderBy(MkDistributionAmountFlow::getCreateTime, false), MkDistributionAmountFlowVO.class); Map map = BeanUtil.beanToMap(pageInfo); map.put("totalAmount", getOne(new QueryWrapper().eq(MkDistributionAmountFlow::getShopId, shopId) .in(MkDistributionAmountFlow::getType, TableValueConstant.DistributionAmountFlow.Type.MANUAL_RECHARGE.getCode(), TableValueConstant.DistributionAmountFlow.Type.SELF_RECHARGE.getCode()) diff --git a/cash-service/pom.xml b/cash-service/pom.xml index b4df5003..797e93d9 100644 --- a/cash-service/pom.xml +++ b/cash-service/pom.xml @@ -99,5 +99,28 @@ 8.0.2.Final + + + io.micrometer + micrometer-tracing-bridge-brave + + + + io.micrometer + micrometer-observation + + + + + io.zipkin.reporter2 + zipkin-reporter-brave + + + + org.springframework.boot + spring-boot-starter-actuator + + +