1. 链路搞定

2. sentinel 实例化有 bug, 不知道会不会影响熔断
This commit is contained in:
zhaowenyuan 2024-05-10 16:06:35 +08:00
parent d640f8a285
commit cef8d8f42f
9 changed files with 45 additions and 22 deletions

View File

@ -14,11 +14,6 @@ package com.chushang.common.feign.annotation;/*
* limitations under the License.
*/
import com.chushang.common.feign.interceptor.FeignHeaderInterceptor;
import com.chushang.common.feign.interceptor.MdcInterceptor;
import com.chushang.common.feign.registrar.MdcFilterRegistrar;
import com.chushang.common.feign.registrar.TransferFeginFilterRegistrar;
import com.chushang.common.feign.registrar.TransferFilterRegistrar;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.cloud.openfeign.ChushangFeignClientsRegistrar;

View File

@ -8,13 +8,16 @@ package com.chushang.common.feign.interceptor;
import com.chushang.common.core.constant.CommonConstants;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
@Slf4j
public class MdcInterceptor implements RequestInterceptor {
public MdcInterceptor() {
}
public void apply(RequestTemplate template) {
log.info("TRACE_ID : -------- {}", MDC.get(CommonConstants.TRACE_ID));
template.header(CommonConstants.TRACE_ID, MDC.get(CommonConstants.TRACE_ID));
template.header(CommonConstants.SPAN, MDC.get(CommonConstants.SPAN));
}

View File

@ -2,6 +2,7 @@ package com.chushang;
import com.chushang.common.core.enums.AppStartType;
import com.chushang.common.feign.annotation.EnableOnnFeignClients;
import com.chushang.common.feign.annotation.EnableTransferFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
@ -21,6 +22,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableOnnFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
@ServletComponentScan
@EnableTransferFeign
public class AuthApplication extends SpringBootServletInitializer
{
private final static Logger log = LoggerFactory.getLogger(AuthApplication.class);

View File

@ -18,7 +18,7 @@
<property name="log.env" value="${plumelog.env}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} TRACE[%X{trace:-}/%X{span:-}] [%clr(%5p) %clr(${PID:- } %clr(%15.15t){faint}] %clr(---){faint}){magenta} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/>
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} TRACE[%X{traceId:-} / %X{span:-}] [%clr(%5p) %clr(${PID:- } %clr(%15.15t){faint}] %clr(---){faint}){magenta} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"

View File

@ -100,7 +100,7 @@
<!-- </appender>-->
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="info">
<root level="debug">
<appender-ref ref="console"/>
<appender-ref ref="info"/>
<appender-ref ref="debug"/>

View File

@ -2,16 +2,12 @@ package com.chushang.oss;
import com.chushang.common.core.enums.AppStartType;
import com.chushang.common.feign.annotation.EnableOnnFeignClients;
import com.chushang.common.feign.annotation.EnableTransferFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import javax.sql.DataSource;
/**
* @auther: zhao
* @date: 2024/4/29 10:50
@ -19,7 +15,7 @@ import javax.sql.DataSource;
@EnableDiscoveryClient
@EnableOnnFeignClients
@SpringBootApplication
@EnableTransferFeign
//@EnableTransferFeign
public class OssApplication {
private final static Logger log = LoggerFactory.getLogger(OssApplication.class);

View File

@ -18,7 +18,7 @@
<property name="log.env" value="${plumelog.env}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} TRACE[%X{trace:-}/%X{span:-}] [%clr(%5p) %clr(${PID:- } %clr(%15.15t){faint}] %clr(---){faint}){magenta} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/>
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} TRACE[%X{traceId:-} / %X{span:-}] [%clr(%5p) %clr(${PID:- } %clr(%15.15t){faint}] %clr(---){faint}){magenta} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"

View File

@ -0,0 +1,24 @@
#spring settings
server:
servlet:
encoding:
force: true
charset: UTF-8
enabled: true
session:
cookie:
name: sentinel_dashboard_cookie
# #logging settings
#logging:
# file:
# name: ${user.home}/logs/csp/sentinel-dashboard.log
# pattern:
# file: %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
# level: info
auth:
filter:
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
username: sentinel
password: sentinel
# todo 需要配置mongo 数据源

View File

@ -8,21 +8,24 @@ spring:
name: @artifactId@
cloud:
nacos:
discovery:
server-addr: ${nacos.host}
username: ${nacos.username}
password: ${nacos.password}
discovery:
server-addr: ${spring.cloud.nacos.server-addr}
namespace: ${nacos.namespace}
group: ${nacos.group}
service: ${spring.application.name}
config:
server-addr: ${spring.cloud.nacos.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
server-addr: ${spring.cloud.nacos.discovery.server-addr}
file-extension: yml
file-extension: yaml
refresh-enabled: true
shared-configs:
- dataId: application-admin-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: COMMON_GROUP
- dataId: application-log-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
group: COMMON_GROUP
refresh: true
- dataId: application-common.${spring.cloud.nacos.config.file-extension}
group: ${nacos.group}
refresh: ${spring.cloud.nacos.config.refresh-enabled}
profiles:
active: @profiles.active@
sentinel: