Commit 5683341a authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents 3cf0c9fd c73408ea
......@@ -34,6 +34,7 @@
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov-dev</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>DEBUG</profiles.log.level>
</properties>
</profile>
<profile>
......@@ -45,10 +46,14 @@
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/</profiles.rabbitmq.virtualhost>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>DEBUG</profiles.log.level>
</properties>
</profile>
<profile>
......@@ -64,6 +69,7 @@
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>stp</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>INFO</profiles.log.level>
</properties>
</profile>
</profiles>
......@@ -130,6 +136,7 @@
<version>1.64</version>
</dependency>
<!-- 虹软人脸解析 -->
<dependency>
<groupId>com.arcsoft.face</groupId>
<artifactId>arcsoft-sdk-face</artifactId>
......
package com.mortals.xhx.base.framework.aspect;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.pdu.access.AccessLogPdu;
import com.mortals.xhx.module.MessageProducer;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
......@@ -10,9 +15,12 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.util.ContentCachingRequestWrapper;
......@@ -36,6 +44,11 @@ import java.util.Map;
@Profile({"default", "develop", "test"})
public class WebLogAspect {
@Value("${spring.application.name:gateway}")
private String appName;
@Autowired
private MessageProducer messageProducer;
private static final String TRACE_ID = "traceId";
private static final String SPAN_ID = "spanId";
private static final String PSPAN_ID = "pspanId";
......@@ -58,6 +71,7 @@ public class WebLogAspect {
HttpServletRequest request = attributes.getRequest();
// log.debug("请求路径 {} ,进入方法 {}", request.getRequestURI(), joinPoint.getSignature().getDeclaringTypeName() + ":" + joinPoint.getSignature().getName());
MDC.put("req", getRequestInfo(request).toJSONString());
MDC.put("reqParams", getRequestInfoParams(request).toJSONString());
MDC.put("startTime", String.valueOf(System.currentTimeMillis()));
}
......@@ -78,14 +92,50 @@ public class WebLogAspect {
long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime));
if (result instanceof String) {
log.info(" \n 请求路径:{} 耗时:{}ms \n traceId:{} pspanId:{} spanId:{} \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime,traceId,pspanId,spanId, map.getOrDefault("req", ""), result);
log.debug(" \n 请求路径:{} 耗时:{}ms \n traceId:{} pspanId:{} spanId:{} \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, traceId, pspanId, spanId, map.getOrDefault("req", ""), result);
} else {
log.info(" \n 请求路径:{} 耗时:{}ms \n traceId:{} pspanId:{} spanId:{} \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime,traceId,pspanId,spanId, map.getOrDefault("req", ""), JSON.toJSONString(result));
log.debug(" \n 请求路径:{} 耗时:{}ms \n traceId:{} pspanId:{} spanId:{} \n 请求报文:{} \n 响应报文:{}"
, request.getRequestURI(), takeTime, traceId, pspanId, spanId, map.getOrDefault("req", ""), JSON.toJSONString(result));
}
if (!ObjectUtils.isEmpty(pspanId) && !ObjectUtils.isEmpty(spanId)) {
//paspId
spanId = String.valueOf(Integer.parseInt(spanId) + 1);
pspanId = spanId;
}else{
spanId="1";
pspanId="0";
}
AccessLogPdu accessLogPdu = new AccessLogPdu();
accessLogPdu.initAttrValue();
accessLogPdu.setAppName(appName);
accessLogPdu.setTraceID(traceId == null ? IdUtil.objectId() : traceId);
accessLogPdu.setPspanId(Integer.parseInt(pspanId));
accessLogPdu.setSpanId(Integer.parseInt(spanId));
accessLogPdu.setSchemaData(request.getScheme());
accessLogPdu.setHostName(NetUtil.getLocalHostName());
accessLogPdu.setUri(request.getRequestURI());
accessLogPdu.setTargetServer(appName);
accessLogPdu.setRequestIp(request.getRemoteAddr());
accessLogPdu.setUa(request.getHeader("User-Agent"));
accessLogPdu.setRequestTime(new Date(Long.parseLong(startTime)));
accessLogPdu.setLogTime(new Date());
accessLogPdu.setMethod(request.getMethod());
accessLogPdu.setResponseTime(new Date());
accessLogPdu.setDuration(takeTime);
//accessLogPdu.setRequestData(map.getOrDefault("reqParams", ""));
if (result instanceof String) {
//accessLogPdu.setResponseData(result.toString());
} else {
//accessLogPdu.setResponseData(JSON.toJSONString(result));
}
log.info("accessLog:{}",JSON.toJSONString(accessLogPdu));
messageProducer.syncAccessSend(accessLogPdu);
}
}
......@@ -118,4 +168,30 @@ public class WebLogAspect {
}
return requestInfo;
}
/**
* 读取请求信息,如果是表单则转换为json
*/
private JSONObject getRequestInfoParams(HttpServletRequest req) {
JSONObject requestInfo = new JSONObject();
try {
if (req.getQueryString() != null) {
requestInfo.put("queryString", URLDecoder.decode(req.getQueryString(), "UTF-8"));
}
if (req instanceof ContentCachingRequestWrapper) {
ContentCachingRequestWrapper wrapper = (ContentCachingRequestWrapper) req;
String bodyStr = new String(wrapper.getContentAsByteArray(), StandardCharsets.UTF_8);
if (bodyStr.startsWith("{")) {
JSONObject jsonObject = JSON.parseObject(bodyStr);
requestInfo.put("requestBody", jsonObject);
}
}
} catch (Exception e) {
log.error("解析请求失败", e);
requestInfo.put("parseError", e.getMessage());
}
return requestInfo;
}
}
......@@ -31,7 +31,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
private SiteService siteService;
@Override
/* @Override
public void putCache(String key, AreaEntity data) {
super.putCache(key, data);
//加载孩子关系
......@@ -42,7 +42,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
cacheService.lpush(childKey, item);
});
}
}
}*/
@Override
protected String getExtKey(AreaEntity data) {
......
......@@ -616,9 +616,6 @@ public class SiteEntity extends SiteVo {
this.modelIds = modelIds;
}
@Override
public int hashCode() {
return this.getId().hashCode();
......
......@@ -220,7 +220,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
public List<SiteEntity> getFlatSitesByAreaCode(String areaCode, Context context) {
List<SiteEntity> siteList = new ArrayList<>();
if (ObjectUtils.isEmpty(areaCode)) {
throw new AppException("区域编码不能为空!");
}
......@@ -228,13 +227,17 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
if (ObjectUtils.isEmpty(areaEntity)) {
throw new AppException(String.format("区域不存在!区域编码:%s", areaCode));
}
String matchCode = areaCode.replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode+"%");
List<SiteEntity> siteEntities = this.find(siteQuery);
List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
for (SiteEntity siteEntity : siteEntities) {
boolean bool = getSite(areaCode, siteEntity.getAreaCode(), siteList, siteEntity);
if (bool) continue;
}
return siteList;
//List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
// for (SiteEntity siteEntity : siteEntities) {
// boolean bool = getSite(areaCode, siteEntity.getAreaCode(), siteList, siteEntity);
// if (bool) continue;
// }
return siteEntities;
}
@Override
......@@ -252,25 +255,31 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
throw new AppException(String.format("区域不存在!区域编码:%s", siteCache.getAreaCode()));
}
List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
;
for (SiteEntity siteEntity : siteEntities) {
boolean bool = getSite(siteCache.getAreaCode(), siteEntity.getAreaCode(), siteList, siteEntity);
if (bool) continue;
}
return siteList;
String matchCode = siteCache.getAreaCode().replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode+"%");
List<SiteEntity> siteEntities = this.find(siteQuery);
//
// List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
// ;
// for (SiteEntity siteEntity : siteEntities) {
// boolean bool = getSite(siteCache.getAreaCode(), siteEntity.getAreaCode(), siteList, siteEntity);
// if (bool) continue;
//
// }
return siteEntities;
}
private boolean getSite(String rootAreaCode, String areaCode, List<SiteEntity> siteList, SiteEntity siteEntity) {
// AreaEntity areaTemp = areaService.getExtCache(siteEntity.getAreaCode());
if (rootAreaCode.equals(areaCode)) {
siteList.add(siteEntity);
log.info("add site:{}", siteEntity.getSiteCode());
//log.info("add site:{}", siteEntity.getSiteCode());
return true;
} else {
AreaEntity areaTemp = areaService.getExtCache(areaCode);
if (!ObjectUtils.isEmpty(areaTemp) && !ObjectUtils.isEmpty(areaTemp.getPid())) {
//根据子节点查找父节点
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().iid(areaTemp.getPid()));
if (!ObjectUtils.isEmpty(areaEntity)) {
return getSite(rootAreaCode, areaEntity.getAreaCode(), siteList, siteEntity);
......
......@@ -189,7 +189,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
int code=1;
try {
if(CollectionUtils.isNotEmpty(query.getAreaCodeList())){
List<SiteEntity> siteEntityList= query.getAreaCodeList().stream().flatMap(areaId ->
List<SiteEntity> siteEntityList= query.getAreaCodeList().parallelStream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).distinct().collect(Collectors.toList());
model.put("data", siteEntityList);
......
spring:
main:
allow-bean-definition-overriding: true
application:
log:
level:@profiles.log.level@
......@@ -16,6 +16,12 @@ spring:
default-property-inclusion: NON_NULL
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
rabbitmq:
host: @profiles.rabbitmq.host@
port: @profiles.rabbitmq.port@
username: @profiles.rabbitmq.username@
password: @profiles.rabbitmq.password@
virtualHost: @profiles.rabbitmq.virtualhost@
dao:
exceptiontranslation:
enabled: false
......
......@@ -24,6 +24,12 @@
<artifactId>mortals-framework-springcloud</artifactId>
</dependency>
<!-- 实现对 RabbitMQ 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- <dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
......
package com.mortals.xhx.common.key;
package com.mortals.xhx.common.keys;
/**
* rabbit 队列key定义
......
......@@ -7,7 +7,7 @@ import com.mortals.framework.model.BaseEntityLong;
* 访问日志Pdu对象
*
* @author zxfei
* @date 2022-08-19
* @date 2022-08-22
*/
public class AccessLogPdu extends BaseEntityLong {
......@@ -49,10 +49,6 @@ public class AccessLogPdu extends BaseEntityLong {
* 请求方式
*/
private String method;
/**
* 协议
*/
private String schema;
/**
* 用户浏览器UA
*/
......@@ -85,6 +81,10 @@ public class AccessLogPdu extends BaseEntityLong {
* 持续时间,单位毫秒
*/
private Long duration;
/**
* 协议
*/
private String schemaData;
/** 开始 主键ID */
private Long idStart;
......@@ -143,9 +143,6 @@ public class AccessLogPdu extends BaseEntityLong {
/** 请求方式 */
private List<String> methodList;
/** 协议 */
private List<String> schemaList;
/** 用户浏览器UA */
private List<String> uaList;
......@@ -206,6 +203,9 @@ public class AccessLogPdu extends BaseEntityLong {
/** 结束 创建时间 */
private String createTimeEnd;
/** 协议 */
private List<String> schemaDataList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<AccessLogPdu> orConditionList;
......@@ -340,20 +340,6 @@ public class AccessLogPdu extends BaseEntityLong {
public void setMethod(String method){
this.method = method;
}
/**
* 获取 协议
* @return String
*/
public String getSchema(){
return schema;
}
/**
* 设置 协议
* @param schema
*/
public void setSchema(String schema){
this.schema = schema;
}
/**
* 获取 用户浏览器UA
* @return String
......@@ -466,6 +452,20 @@ public class AccessLogPdu extends BaseEntityLong {
public void setDuration(Long duration){
this.duration = duration;
}
/**
* 获取 协议
* @return String
*/
public String getSchemaData(){
return schemaData;
}
/**
* 设置 协议
* @param schemaData
*/
public void setSchemaData(String schemaData){
this.schemaData = schemaData;
}
/**
* 获取 开始 主键ID
......@@ -764,21 +764,6 @@ public class AccessLogPdu extends BaseEntityLong {
public void setMethodList(List<String> methodList){
this.methodList = methodList;
}
/**
* 获取 协议
* @return schemaList
*/
public List<String> getSchemaList(){
return this.schemaList;
}
/**
* 设置 协议
* @param schemaList
*/
public void setSchemaList(List<String> schemaList){
this.schemaList = schemaList;
}
/**
* 获取 用户浏览器UA
* @return uaList
......@@ -1095,6 +1080,21 @@ public class AccessLogPdu extends BaseEntityLong {
this.createTimeEnd = createTimeEnd;
}
/**
* 获取 协议
* @return schemaDataList
*/
public List<String> getSchemaDataList(){
return this.schemaDataList;
}
/**
* 设置 协议
* @param schemaDataList
*/
public void setSchemaDataList(List<String> schemaDataList){
this.schemaDataList = schemaDataList;
}
/**
* 设置 主键ID
* @param id
......@@ -1364,25 +1364,6 @@ public class AccessLogPdu extends BaseEntityLong {
}
/**
* 设置 协议
* @param schema
*/
public AccessLogPdu schema(String schema){
setSchema(schema);
return this;
}
/**
* 设置 协议
* @param schemaList
*/
public AccessLogPdu schemaList(List<String> schemaList){
this.schemaList = schemaList;
return this;
}
/**
* 设置 用户浏览器UA
* @param ua
......@@ -1553,6 +1534,25 @@ public class AccessLogPdu extends BaseEntityLong {
/**
* 设置 协议
* @param schemaData
*/
public AccessLogPdu schemaData(String schemaData){
setSchemaData(schemaData);
return this;
}
/**
* 设置 协议
* @param schemaDataList
*/
public AccessLogPdu schemaDataList(List<String> schemaDataList){
this.schemaDataList = schemaDataList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......@@ -1621,8 +1621,6 @@ public class AccessLogPdu extends BaseEntityLong {
this.method = "";
this.schema = "http";
this.ua = "";
this.uri = "";
......@@ -1638,5 +1636,7 @@ public class AccessLogPdu extends BaseEntityLong {
this.responseTime = null;
this.duration = null;
this.schemaData = "http";
}
}
\ No newline at end of file
package com.mortals.xhx.base.framework.service;
package com.mortals.xhx.module;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.common.keys.QueueKey;
import com.mortals.xhx.common.pdu.access.AccessLogPdu;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
......
......@@ -95,11 +95,7 @@
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- 实现对 RabbitMQ 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- <dependency>
......
......@@ -3,7 +3,7 @@ package com.mortals.xhx.base.framework.filter;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.ObjectUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.framework.service.MessageProducer;
import com.mortals.xhx.module.MessageProducer;
import com.mortals.xhx.common.pdu.access.AccessLogPdu;
import com.mortals.xhx.common.utils.IpUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -88,36 +88,23 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
Route route = getGatewayRoute(exchange);
// String ipAddress = WebUtils.get(request);
String ipAddress = IpUtils.getRealIpAddress(exchange.getRequest());
Map<String, String> headers = exchange.getRequest().getHeaders().toSingleValueMap();
AccessLogPdu accessLogPdu = new AccessLogPdu();
accessLogPdu.initAttrValue();
accessLogPdu.setAppName(appName);
accessLogPdu.setTraceID(headers.getOrDefault(TRACE_ID,""));
accessLogPdu.setPspanId(Integer.parseInt(headers.getOrDefault(PSPAN_ID,"0")));
accessLogPdu.setSpanId(Integer.parseInt(headers.getOrDefault(SPAN_ID,"0")));
accessLogPdu.setSchema(request.getURI().getScheme());
accessLogPdu.setSpanId(Integer.parseInt(headers.getOrDefault(SPAN_ID,"1")));
accessLogPdu.setSchemaData(request.getURI().getScheme());
accessLogPdu.setHostName(NetUtil.getLocalHostName());
accessLogPdu.setUri(requestPath);
accessLogPdu.setTargetServer(route.getId());
accessLogPdu.setRequestIp(IpUtils.getRealIpAddress(exchange.getRequest()));
accessLogPdu.setUa(headers.getOrDefault("User-Agent",""));
accessLogPdu.setRequestTime(new Date());
accessLogPdu.setLogTime(new Date());
accessLogPdu.setMethod(request.getMethodValue());
//accessLogPdu.setRequestData(paramStr);
// GatewayLog gatewayLog = new GatewayLog();
// gatewayLog.setSchema(request.getURI().getScheme());
// gatewayLog.setRequestMethod(request.getMethodValue());
// gatewayLog.setRequestPath(requestPath);
// gatewayLog.setTargetServer(route.getId());
// gatewayLog.setRequestTime(new Date());
// gatewayLog.setIp(ipAddress);
MediaType mediaType = request.getHeaders().getContentType();
if (MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType) || MediaType.APPLICATION_JSON.isCompatibleWith(mediaType)) {
return writeBodyLog(exchange, chain, accessLogPdu);
......@@ -260,6 +247,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
// accessLogPdu.setResponseTime(responseTime);
// 计算执行时间
long executeTime = (responseTime.getTime() - accessLogPdu.getRequestTime().getTime());
accessLogPdu.setResponseTime(responseTime);
accessLogPdu.setDuration(executeTime);
// 获取响应类型,如果是 json 就打印
String originalResponseContentType = exchange.getAttribute(ServerWebExchangeUtils.ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR);
......
package com.mortals.xhx.base.framework.filter;
import cn.hutool.extra.servlet.ServletUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.framework.service.MessageProducer;
import com.mortals.xhx.module.MessageProducer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.Charsets;
import org.reactivestreams.Publisher;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
......@@ -20,15 +17,11 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR;
......
package com.mortals.xhx.base.framework.filter;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.base.framework.config.CustomGatewayProperties;
import com.mortals.xhx.base.framework.service.MessageProducer;
import com.mortals.xhx.common.pdu.access.AccessLogPdu;
import com.mortals.xhx.common.utils.IpUtils;
import com.sun.jndi.toolkit.url.UrlUtil;
import com.mortals.xhx.module.MessageProducer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
......@@ -24,18 +15,14 @@ import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import javax.sound.midi.Track;
import java.net.InetAddress;
import java.net.URI;
import java.nio.CharBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicReference;
......@@ -74,8 +61,8 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
ServerHttpRequest newRequest = exchange.getRequest().mutate()
.header(TRACE_ID, traceId)
.header(SPAN_ID, pspanId.toString())
.header(PSPAN_ID, spanId.toString())
.header(PSPAN_ID, pspanId.toString())
.header(SPAN_ID, spanId.toString())
.build();
return chain.filter(exchange.mutate().request(newRequest).build());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment