Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
db8a61d7
Commit
db8a61d7
authored
Aug 19, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改网关日志
parent
356c858d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1363 additions
and
549 deletions
+1363
-549
common-lib/src/main/java/com/mortals/xhx/common/pdu/access/AccessLogPdu.java
.../java/com/mortals/xhx/common/pdu/access/AccessLogPdu.java
+1022
-510
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/AccessLogFilter.java
...om/mortals/xhx/base/framework/filter/AccessLogFilter.java
+296
-0
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
...tals/xhx/base/framework/filter/GatewayResponseFilter.java
+1
-1
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalCacheRequestFilter.java
...s/xhx/base/framework/filter/GlobalCacheRequestFilter.java
+2
-2
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalLogFilter.java
...om/mortals/xhx/base/framework/filter/GlobalLogFilter.java
+42
-36
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/access/AccessLogPdu.java
View file @
db8a61d7
package
com.mortals.xhx.common.pdu.access
;
package
com.mortals.xhx.common.pdu.access
;
import
com.mortals.framework.model.BaseEntityLong
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.mortals.framework.model.BaseEntityLong
;
/**
/**
* 访问日志Pdu对象
* 访问日志Pdu对象
*
*
* @author zxfei
* @author zxfei
* @date 2022-08-17
* @date 2022-08-19
*/
*/
public
class
AccessLogPdu
extends
BaseEntityLong
{
public
class
AccessLogPdu
extends
BaseEntityLong
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/**
/**
* 追踪
Id
* Trace
Id
*/
*/
private
String
traceID
;
private
String
traceID
;
/**
/**
* 应用名称
* 父服务调用id
*/
*/
private
Integer
pspanId
;
/**
* 当前服务跨度Id
*/
private
Integer
spanId
;
/**
* 应用名称
*/
private
String
appName
;
private
String
appName
;
/**
/**
* 实例IP
* 实例IP
*/
*/
private
String
hostName
;
private
String
hostName
;
/**
/**
* 日志等级
* 目标服务
*/
*/
private
String
targetServer
;
/**
* 日志等级
*/
private
String
logLevel
;
private
String
logLevel
;
/**
/**
* 请求者IP
* 请求者IP
*/
*/
private
String
requestIp
;
private
String
requestIp
;
/**
/**
* 请求方式
* 请求方式
*/
*/
private
String
method
;
private
String
method
;
/**
/**
* 用户浏览器UA
* 协议
*/
*/
private
String
schema
;
/**
* 用户浏览器UA
*/
private
String
ua
;
private
String
ua
;
/**
/**
* 请求URI
* 请求URI
*/
*/
private
String
uri
;
private
String
uri
;
/**
/**
* 请求参数,json序列化
* 请求参数,json序列化
*/
*/
private
String
request
Param
;
private
String
request
Data
;
/**
/**
* 响应结果
* 响应结果,
*/
*/
private
String
response
;
private
String
response
Data
;
/**
/**
* 日志产生时间
* 日志产生时间
*/
*/
private
Date
logTime
;
private
Date
logTime
;
/**
/**
* 持续时间,单位毫秒
* 请求时间
*/
*/
private
Integer
duration
;
private
Date
requestTime
;
/**
* 响应时间
*/
private
Date
responseTime
;
/**
* 持续时间,单位毫秒
*/
private
Long
duration
;
/** 开始 主键ID
,主键,自增长
*/
/** 开始 主键ID */
private
Long
idStart
;
private
Long
idStart
;
/** 结束 主键ID
,主键,自增长
*/
/** 结束 主键ID */
private
Long
idEnd
;
private
Long
idEnd
;
/** 增加 主键ID
,主键,自增长
*/
/** 增加 主键ID */
private
Long
idIncrement
;
private
Long
idIncrement
;
/** 主键ID
,主键,自增长
列表 */
/** 主键ID列表 */
private
List
<
Long
>
idList
;
private
List
<
Long
>
idList
;
/**
追踪
Id */
/**
Trace
Id */
private
List
<
String
>
traceIDList
;
private
List
<
String
>
traceIDList
;
/** 开始 父服务调用id */
private
Integer
pspanIdStart
;
/** 结束 父服务调用id */
private
Integer
pspanIdEnd
;
/** 增加 父服务调用id */
private
Integer
pspanIdIncrement
;
/** 父服务调用id列表 */
private
List
<
Integer
>
pspanIdList
;
/** 开始 当前服务跨度Id */
private
Integer
spanIdStart
;
/** 结束 当前服务跨度Id */
private
Integer
spanIdEnd
;
/** 增加 当前服务跨度Id */
private
Integer
spanIdIncrement
;
/** 当前服务跨度Id列表 */
private
List
<
Integer
>
spanIdList
;
/** 应用名称 */
/** 应用名称 */
private
List
<
String
>
appNameList
;
private
List
<
String
>
appNameList
;
/** 实例IP */
/** 实例IP */
private
List
<
String
>
hostNameList
;
private
List
<
String
>
hostNameList
;
/** 目标服务 */
private
List
<
String
>
targetServerList
;
/** 日志等级 */
/** 日志等级 */
private
List
<
String
>
logLevelList
;
private
List
<
String
>
logLevelList
;
...
@@ -94,6 +143,9 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -94,6 +143,9 @@ public class AccessLogPdu extends BaseEntityLong {
/** 请求方式 */
/** 请求方式 */
private
List
<
String
>
methodList
;
private
List
<
String
>
methodList
;
/** 协议 */
private
List
<
String
>
schemaList
;
/** 用户浏览器UA */
/** 用户浏览器UA */
private
List
<
String
>
uaList
;
private
List
<
String
>
uaList
;
...
@@ -101,10 +153,10 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -101,10 +153,10 @@ public class AccessLogPdu extends BaseEntityLong {
private
List
<
String
>
uriList
;
private
List
<
String
>
uriList
;
/** 请求参数,json序列化 */
/** 请求参数,json序列化 */
private
List
<
String
>
request
Param
List
;
private
List
<
String
>
request
Data
List
;
/** 响应结果 */
/** 响应结果
,
*/
private
List
<
String
>
responseList
;
private
List
<
String
>
response
Data
List
;
/** 开始 日志产生时间 */
/** 开始 日志产生时间 */
private
String
logTimeStart
;
private
String
logTimeStart
;
...
@@ -112,17 +164,29 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -112,17 +164,29 @@ public class AccessLogPdu extends BaseEntityLong {
/** 结束 日志产生时间 */
/** 结束 日志产生时间 */
private
String
logTimeEnd
;
private
String
logTimeEnd
;
/** 开始 请求时间 */
private
String
requestTimeStart
;
/** 结束 请求时间 */
private
String
requestTimeEnd
;
/** 开始 响应时间 */
private
String
responseTimeStart
;
/** 结束 响应时间 */
private
String
responseTimeEnd
;
/** 开始 持续时间,单位毫秒 */
/** 开始 持续时间,单位毫秒 */
private
Integer
durationStart
;
private
Long
durationStart
;
/** 结束 持续时间,单位毫秒 */
/** 结束 持续时间,单位毫秒 */
private
Integer
durationEnd
;
private
Long
durationEnd
;
/** 增加 持续时间,单位毫秒 */
/** 增加 持续时间,单位毫秒 */
private
Integer
durationIncrement
;
private
Long
durationIncrement
;
/** 持续时间,单位毫秒列表 */
/** 持续时间,单位毫秒列表 */
private
List
<
Integer
>
durationList
;
private
List
<
Long
>
durationList
;
/** 开始 创建用户 */
/** 开始 创建用户 */
private
Long
createUserIdStart
;
private
Long
createUserIdStart
;
...
@@ -151,943 +215,1379 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -151,943 +215,1379 @@ public class AccessLogPdu extends BaseEntityLong {
public
AccessLogPdu
(){}
public
AccessLogPdu
(){}
/**
/**
* 获取 追踪
Id
* 获取 Trace
Id
* @return String
* @return String
*/
*/
public
String
getTraceID
(){
public
String
getTraceID
(){
return
traceID
;
return
traceID
;
}
}
/**
/**
* 设置 追踪
Id
* 设置 Trace
Id
* @param traceID
* @param traceID
*/
*/
public
void
setTraceID
(
String
traceID
){
public
void
setTraceID
(
String
traceID
){
this
.
traceID
=
traceID
;
this
.
traceID
=
traceID
;
}
}
/**
/**
* 获取 应用名称
* 获取 父服务调用id
* @return String
* @return Integer
*/
*/
public
Integer
getPspanId
(){
return
pspanId
;
}
/**
* 设置 父服务调用id
* @param pspanId
*/
public
void
setPspanId
(
Integer
pspanId
){
this
.
pspanId
=
pspanId
;
}
/**
* 获取 当前服务跨度Id
* @return Integer
*/
public
Integer
getSpanId
(){
return
spanId
;
}
/**
* 设置 当前服务跨度Id
* @param spanId
*/
public
void
setSpanId
(
Integer
spanId
){
this
.
spanId
=
spanId
;
}
/**
* 获取 应用名称
* @return String
*/
public
String
getAppName
(){
public
String
getAppName
(){
return
appName
;
return
appName
;
}
}
/**
/**
* 设置 应用名称
* 设置 应用名称
* @param appName
* @param appName
*/
*/
public
void
setAppName
(
String
appName
){
public
void
setAppName
(
String
appName
){
this
.
appName
=
appName
;
this
.
appName
=
appName
;
}
}
/**
/**
* 获取 实例IP
* 获取 实例IP
* @return String
* @return String
*/
*/
public
String
getHostName
(){
public
String
getHostName
(){
return
hostName
;
return
hostName
;
}
}
/**
/**
* 设置 实例IP
* 设置 实例IP
* @param hostName
* @param hostName
*/
*/
public
void
setHostName
(
String
hostName
){
public
void
setHostName
(
String
hostName
){
this
.
hostName
=
hostName
;
this
.
hostName
=
hostName
;
}
}
/**
/**
* 获取 日志等级
* 获取 目标服务
* @return String
* @return String
*/
*/
public
String
getTargetServer
(){
return
targetServer
;
}
/**
* 设置 目标服务
* @param targetServer
*/
public
void
setTargetServer
(
String
targetServer
){
this
.
targetServer
=
targetServer
;
}
/**
* 获取 日志等级
* @return String
*/
public
String
getLogLevel
(){
public
String
getLogLevel
(){
return
logLevel
;
return
logLevel
;
}
}
/**
/**
* 设置 日志等级
* 设置 日志等级
* @param logLevel
* @param logLevel
*/
*/
public
void
setLogLevel
(
String
logLevel
){
public
void
setLogLevel
(
String
logLevel
){
this
.
logLevel
=
logLevel
;
this
.
logLevel
=
logLevel
;
}
}
/**
/**
* 获取 请求者IP
* 获取 请求者IP
* @return String
* @return String
*/
*/
public
String
getRequestIp
(){
public
String
getRequestIp
(){
return
requestIp
;
return
requestIp
;
}
}
/**
/**
* 设置 请求者IP
* 设置 请求者IP
* @param requestIp
* @param requestIp
*/
*/
public
void
setRequestIp
(
String
requestIp
){
public
void
setRequestIp
(
String
requestIp
){
this
.
requestIp
=
requestIp
;
this
.
requestIp
=
requestIp
;
}
}
/**
/**
* 获取 请求方式
* 获取 请求方式
* @return String
* @return String
*/
*/
public
String
getMethod
(){
public
String
getMethod
(){
return
method
;
return
method
;
}
}
/**
/**
* 设置 请求方式
* 设置 请求方式
* @param method
* @param method
*/
*/
public
void
setMethod
(
String
method
){
public
void
setMethod
(
String
method
){
this
.
method
=
method
;
this
.
method
=
method
;
}
}
/**
/**
* 获取 用户浏览器UA
* 获取 协议
* @return String
* @return String
*/
*/
public
String
getSchema
(){
return
schema
;
}
/**
* 设置 协议
* @param schema
*/
public
void
setSchema
(
String
schema
){
this
.
schema
=
schema
;
}
/**
* 获取 用户浏览器UA
* @return String
*/
public
String
getUa
(){
public
String
getUa
(){
return
ua
;
return
ua
;
}
}
/**
/**
* 设置 用户浏览器UA
* 设置 用户浏览器UA
* @param ua
* @param ua
*/
*/
public
void
setUa
(
String
ua
){
public
void
setUa
(
String
ua
){
this
.
ua
=
ua
;
this
.
ua
=
ua
;
}
}
/**
/**
* 获取 请求URI
* 获取 请求URI
* @return String
* @return String
*/
*/
public
String
getUri
(){
public
String
getUri
(){
return
uri
;
return
uri
;
}
}
/**
/**
* 设置 请求URI
* 设置 请求URI
* @param uri
* @param uri
*/
*/
public
void
setUri
(
String
uri
){
public
void
setUri
(
String
uri
){
this
.
uri
=
uri
;
this
.
uri
=
uri
;
}
}
/**
/**
* 获取 请求参数,json序列化
* 获取 请求参数,json序列化
* @return String
* @return String
*/
*/
public
String
getRequest
Param
(){
public
String
getRequest
Data
(){
return
request
Param
;
return
request
Data
;
}
}
/**
/**
* 设置 请求参数,json序列化
* 设置 请求参数,json序列化
* @param requestParam
* @param requestData
*/
*/
public
void
setRequest
Param
(
String
requestParam
){
public
void
setRequest
Data
(
String
requestData
){
this
.
request
Param
=
requestParam
;
this
.
request
Data
=
requestData
;
}
}
/**
/**
* 获取 响应结果
* 获取 响应结果,
* @return String
* @return String
*/
*/
public
String
getResponse
(){
public
String
getResponse
Data
(){
return
response
;
return
response
Data
;
}
}
/**
/**
* 设置 响应结果
* 设置 响应结果,
* @param response
* @param responseData
*/
*/
public
void
setResponse
(
String
response
){
public
void
setResponse
Data
(
String
responseData
){
this
.
response
=
response
;
this
.
response
Data
=
responseData
;
}
}
/**
/**
* 获取 日志产生时间
* 获取 日志产生时间
* @return Date
* @return Date
*/
*/
public
Date
getLogTime
(){
public
Date
getLogTime
(){
return
logTime
;
return
logTime
;
}
}
/**
/**
* 设置 日志产生时间
* 设置 日志产生时间
* @param logTime
* @param logTime
*/
*/
public
void
setLogTime
(
Date
logTime
){
public
void
setLogTime
(
Date
logTime
){
this
.
logTime
=
logTime
;
this
.
logTime
=
logTime
;
}
}
/**
/**
* 获取 持续时间,单位毫秒
* 获取 请求时间
* @return Integer
* @return Date
*/
*/
public
Integer
getDuration
(){
public
Date
getRequestTime
(){
return
requestTime
;
}
/**
* 设置 请求时间
* @param requestTime
*/
public
void
setRequestTime
(
Date
requestTime
){
this
.
requestTime
=
requestTime
;
}
/**
* 获取 响应时间
* @return Date
*/
public
Date
getResponseTime
(){
return
responseTime
;
}
/**
* 设置 响应时间
* @param responseTime
*/
public
void
setResponseTime
(
Date
responseTime
){
this
.
responseTime
=
responseTime
;
}
/**
* 获取 持续时间,单位毫秒
* @return Long
*/
public
Long
getDuration
(){
return
duration
;
return
duration
;
}
}
/**
/**
* 设置 持续时间,单位毫秒
* 设置 持续时间,单位毫秒
* @param duration
* @param duration
*/
*/
public
void
setDuration
(
Integer
duration
){
public
void
setDuration
(
Long
duration
){
this
.
duration
=
duration
;
this
.
duration
=
duration
;
}
}
/**
/**
* 获取 开始 主键ID,主键,自增长
* 获取 开始 主键ID
* @return idStart
* @return idStart
*/
*/
public
Long
getIdStart
(){
public
Long
getIdStart
(){
return
this
.
idStart
;
return
this
.
idStart
;
}
}
/**
/**
* 设置 开始 主键ID,主键,自增长
* 设置 开始 主键ID
* @param idStart
* @param idStart
*/
*/
public
void
setIdStart
(
Long
idStart
){
public
void
setIdStart
(
Long
idStart
){
this
.
idStart
=
idStart
;
this
.
idStart
=
idStart
;
}
}
/**
/**
* 获取 结束 主键ID,主键,自增长
* 获取 结束 主键ID
* @return $idEnd
* @return $idEnd
*/
*/
public
Long
getIdEnd
(){
public
Long
getIdEnd
(){
return
this
.
idEnd
;
return
this
.
idEnd
;
}
}
/**
/**
* 设置 结束 主键ID,主键,自增长
* 设置 结束 主键ID
* @param idEnd
* @param idEnd
*/
*/
public
void
setIdEnd
(
Long
idEnd
){
public
void
setIdEnd
(
Long
idEnd
){
this
.
idEnd
=
idEnd
;
this
.
idEnd
=
idEnd
;
}
}
/**
/**
* 获取 增加 主键ID,主键,自增长
* 获取 增加 主键ID
* @return idIncrement
* @return idIncrement
*/
*/
public
Long
getIdIncrement
(){
public
Long
getIdIncrement
(){
return
this
.
idIncrement
;
return
this
.
idIncrement
;
}
}
/**
/**
* 设置 增加 主键ID,主键,自增长
* 设置 增加 主键ID
* @param idIncrement
* @param idIncrement
*/
*/
public
void
setIdIncrement
(
Long
idIncrement
){
public
void
setIdIncrement
(
Long
idIncrement
){
this
.
idIncrement
=
idIncrement
;
this
.
idIncrement
=
idIncrement
;
}
}
/**
/**
* 获取 主键ID,主键,自增长
* 获取 主键ID
* @return idList
* @return idList
*/
*/
public
List
<
Long
>
getIdList
(){
public
List
<
Long
>
getIdList
(){
return
this
.
idList
;
return
this
.
idList
;
}
}
/**
/**
* 设置 主键ID,主键,自增长
* 设置 主键ID
* @param idList
* @param idList
*/
*/
public
void
setIdList
(
List
<
Long
>
idList
){
public
void
setIdList
(
List
<
Long
>
idList
){
this
.
idList
=
idList
;
this
.
idList
=
idList
;
}
}
/**
/**
* 获取 追踪
Id
* 获取 Trace
Id
* @return traceIDList
* @return traceIDList
*/
*/
public
List
<
String
>
getTraceIDList
(){
public
List
<
String
>
getTraceIDList
(){
return
this
.
traceIDList
;
return
this
.
traceIDList
;
}
}
/**
/**
* 设置 追踪
Id
* 设置 Trace
Id
* @param traceIDList
* @param traceIDList
*/
*/
public
void
setTraceIDList
(
List
<
String
>
traceIDList
){
public
void
setTraceIDList
(
List
<
String
>
traceIDList
){
this
.
traceIDList
=
traceIDList
;
this
.
traceIDList
=
traceIDList
;
}
}
/**
/**
* 获取 应用名称
* 获取 开始 父服务调用id
* @return appNameList
* @return pspanIdStart
*/
*/
public
Integer
getPspanIdStart
(){
return
this
.
pspanIdStart
;
}
/**
* 设置 开始 父服务调用id
* @param pspanIdStart
*/
public
void
setPspanIdStart
(
Integer
pspanIdStart
){
this
.
pspanIdStart
=
pspanIdStart
;
}
/**
* 获取 结束 父服务调用id
* @return $pspanIdEnd
*/
public
Integer
getPspanIdEnd
(){
return
this
.
pspanIdEnd
;
}
/**
* 设置 结束 父服务调用id
* @param pspanIdEnd
*/
public
void
setPspanIdEnd
(
Integer
pspanIdEnd
){
this
.
pspanIdEnd
=
pspanIdEnd
;
}
/**
* 获取 增加 父服务调用id
* @return pspanIdIncrement
*/
public
Integer
getPspanIdIncrement
(){
return
this
.
pspanIdIncrement
;
}
/**
* 设置 增加 父服务调用id
* @param pspanIdIncrement
*/
public
void
setPspanIdIncrement
(
Integer
pspanIdIncrement
){
this
.
pspanIdIncrement
=
pspanIdIncrement
;
}
/**
* 获取 父服务调用id
* @return pspanIdList
*/
public
List
<
Integer
>
getPspanIdList
(){
return
this
.
pspanIdList
;
}
/**
* 设置 父服务调用id
* @param pspanIdList
*/
public
void
setPspanIdList
(
List
<
Integer
>
pspanIdList
){
this
.
pspanIdList
=
pspanIdList
;
}
/**
* 获取 开始 当前服务跨度Id
* @return spanIdStart
*/
public
Integer
getSpanIdStart
(){
return
this
.
spanIdStart
;
}
/**
* 设置 开始 当前服务跨度Id
* @param spanIdStart
*/
public
void
setSpanIdStart
(
Integer
spanIdStart
){
this
.
spanIdStart
=
spanIdStart
;
}
/**
* 获取 结束 当前服务跨度Id
* @return $spanIdEnd
*/
public
Integer
getSpanIdEnd
(){
return
this
.
spanIdEnd
;
}
/**
* 设置 结束 当前服务跨度Id
* @param spanIdEnd
*/
public
void
setSpanIdEnd
(
Integer
spanIdEnd
){
this
.
spanIdEnd
=
spanIdEnd
;
}
/**
* 获取 增加 当前服务跨度Id
* @return spanIdIncrement
*/
public
Integer
getSpanIdIncrement
(){
return
this
.
spanIdIncrement
;
}
/**
* 设置 增加 当前服务跨度Id
* @param spanIdIncrement
*/
public
void
setSpanIdIncrement
(
Integer
spanIdIncrement
){
this
.
spanIdIncrement
=
spanIdIncrement
;
}
/**
* 获取 当前服务跨度Id
* @return spanIdList
*/
public
List
<
Integer
>
getSpanIdList
(){
return
this
.
spanIdList
;
}
/**
* 设置 当前服务跨度Id
* @param spanIdList
*/
public
void
setSpanIdList
(
List
<
Integer
>
spanIdList
){
this
.
spanIdList
=
spanIdList
;
}
/**
* 获取 应用名称
* @return appNameList
*/
public
List
<
String
>
getAppNameList
(){
public
List
<
String
>
getAppNameList
(){
return
this
.
appNameList
;
return
this
.
appNameList
;
}
}
/**
/**
* 设置 应用名称
* 设置 应用名称
* @param appNameList
* @param appNameList
*/
*/
public
void
setAppNameList
(
List
<
String
>
appNameList
){
public
void
setAppNameList
(
List
<
String
>
appNameList
){
this
.
appNameList
=
appNameList
;
this
.
appNameList
=
appNameList
;
}
}
/**
/**
* 获取 实例IP
* 获取 实例IP
* @return hostNameList
* @return hostNameList
*/
*/
public
List
<
String
>
getHostNameList
(){
public
List
<
String
>
getHostNameList
(){
return
this
.
hostNameList
;
return
this
.
hostNameList
;
}
}
/**
/**
* 设置 实例IP
* 设置 实例IP
* @param hostNameList
* @param hostNameList
*/
*/
public
void
setHostNameList
(
List
<
String
>
hostNameList
){
public
void
setHostNameList
(
List
<
String
>
hostNameList
){
this
.
hostNameList
=
hostNameList
;
this
.
hostNameList
=
hostNameList
;
}
}
/**
/**
* 获取 日志等级
* 获取 目标服务
* @return logLevelList
* @return targetServerList
*/
*/
public
List
<
String
>
getTargetServerList
(){
return
this
.
targetServerList
;
}
/**
* 设置 目标服务
* @param targetServerList
*/
public
void
setTargetServerList
(
List
<
String
>
targetServerList
){
this
.
targetServerList
=
targetServerList
;
}
/**
* 获取 日志等级
* @return logLevelList
*/
public
List
<
String
>
getLogLevelList
(){
public
List
<
String
>
getLogLevelList
(){
return
this
.
logLevelList
;
return
this
.
logLevelList
;
}
}
/**
/**
* 设置 日志等级
* 设置 日志等级
* @param logLevelList
* @param logLevelList
*/
*/
public
void
setLogLevelList
(
List
<
String
>
logLevelList
){
public
void
setLogLevelList
(
List
<
String
>
logLevelList
){
this
.
logLevelList
=
logLevelList
;
this
.
logLevelList
=
logLevelList
;
}
}
/**
/**
* 获取 请求者IP
* 获取 请求者IP
* @return requestIpList
* @return requestIpList
*/
*/
public
List
<
String
>
getRequestIpList
(){
public
List
<
String
>
getRequestIpList
(){
return
this
.
requestIpList
;
return
this
.
requestIpList
;
}
}
/**
/**
* 设置 请求者IP
* 设置 请求者IP
* @param requestIpList
* @param requestIpList
*/
*/
public
void
setRequestIpList
(
List
<
String
>
requestIpList
){
public
void
setRequestIpList
(
List
<
String
>
requestIpList
){
this
.
requestIpList
=
requestIpList
;
this
.
requestIpList
=
requestIpList
;
}
}
/**
/**
* 获取 请求方式
* 获取 请求方式
* @return methodList
* @return methodList
*/
*/
public
List
<
String
>
getMethodList
(){
public
List
<
String
>
getMethodList
(){
return
this
.
methodList
;
return
this
.
methodList
;
}
}
/**
/**
* 设置 请求方式
* 设置 请求方式
* @param methodList
* @param methodList
*/
*/
public
void
setMethodList
(
List
<
String
>
methodList
){
public
void
setMethodList
(
List
<
String
>
methodList
){
this
.
methodList
=
methodList
;
this
.
methodList
=
methodList
;
}
}
/**
/**
* 获取 用户浏览器UA
* 获取 协议
* @return uaList
* @return schemaList
*/
*/
public
List
<
String
>
getSchemaList
(){
return
this
.
schemaList
;
}
/**
* 设置 协议
* @param schemaList
*/
public
void
setSchemaList
(
List
<
String
>
schemaList
){
this
.
schemaList
=
schemaList
;
}
/**
* 获取 用户浏览器UA
* @return uaList
*/
public
List
<
String
>
getUaList
(){
public
List
<
String
>
getUaList
(){
return
this
.
uaList
;
return
this
.
uaList
;
}
}
/**
/**
* 设置 用户浏览器UA
* 设置 用户浏览器UA
* @param uaList
* @param uaList
*/
*/
public
void
setUaList
(
List
<
String
>
uaList
){
public
void
setUaList
(
List
<
String
>
uaList
){
this
.
uaList
=
uaList
;
this
.
uaList
=
uaList
;
}
}
/**
/**
* 获取 请求URI
* 获取 请求URI
* @return uriList
* @return uriList
*/
*/
public
List
<
String
>
getUriList
(){
public
List
<
String
>
getUriList
(){
return
this
.
uriList
;
return
this
.
uriList
;
}
}
/**
/**
* 设置 请求URI
* 设置 请求URI
* @param uriList
* @param uriList
*/
*/
public
void
setUriList
(
List
<
String
>
uriList
){
public
void
setUriList
(
List
<
String
>
uriList
){
this
.
uriList
=
uriList
;
this
.
uriList
=
uriList
;
}
}
/**
/**
* 获取 请求参数,json序列化
* 获取 请求参数,json序列化
* @return requestParam
List
* @return requestData
List
*/
*/
public
List
<
String
>
getRequest
Param
List
(){
public
List
<
String
>
getRequest
Data
List
(){
return
this
.
request
Param
List
;
return
this
.
request
Data
List
;
}
}
/**
/**
* 设置 请求参数,json序列化
* 设置 请求参数,json序列化
* @param requestParam
List
* @param requestData
List
*/
*/
public
void
setRequest
ParamList
(
List
<
String
>
requestParam
List
){
public
void
setRequest
DataList
(
List
<
String
>
requestData
List
){
this
.
request
ParamList
=
requestParam
List
;
this
.
request
DataList
=
requestData
List
;
}
}
/**
/**
* 获取 响应结果
* 获取 响应结果,
* @return response
List
* @return responseData
List
*/
*/
public
List
<
String
>
getResponseList
(){
public
List
<
String
>
getResponse
Data
List
(){
return
this
.
responseList
;
return
this
.
response
Data
List
;
}
}
/**
/**
* 设置 响应结果
* 设置 响应结果,
* @param response
List
* @param responseData
List
*/
*/
public
void
setResponse
List
(
List
<
String
>
response
List
){
public
void
setResponse
DataList
(
List
<
String
>
responseData
List
){
this
.
response
List
=
response
List
;
this
.
response
DataList
=
responseData
List
;
}
}
/**
/**
* 获取 开始 日志产生时间
* 获取 开始 日志产生时间
* @return logTimeStart
* @return logTimeStart
*/
*/
public
String
getLogTimeStart
(){
public
String
getLogTimeStart
(){
return
this
.
logTimeStart
;
return
this
.
logTimeStart
;
}
}
/**
/**
* 设置 开始 日志产生时间
* 设置 开始 日志产生时间
* @param logTimeStart
* @param logTimeStart
*/
*/
public
void
setLogTimeStart
(
String
logTimeStart
){
public
void
setLogTimeStart
(
String
logTimeStart
){
this
.
logTimeStart
=
logTimeStart
;
this
.
logTimeStart
=
logTimeStart
;
}
}
/**
/**
* 获取 结束 日志产生时间
* 获取 结束 日志产生时间
* @return logTimeEnd
* @return logTimeEnd
*/
*/
public
String
getLogTimeEnd
(){
public
String
getLogTimeEnd
(){
return
this
.
logTimeEnd
;
return
this
.
logTimeEnd
;
}
}
/**
/**
* 设置 结束 日志产生时间
* 设置 结束 日志产生时间
* @param logTimeEnd
* @param logTimeEnd
*/
*/
public
void
setLogTimeEnd
(
String
logTimeEnd
){
public
void
setLogTimeEnd
(
String
logTimeEnd
){
this
.
logTimeEnd
=
logTimeEnd
;
this
.
logTimeEnd
=
logTimeEnd
;
}
}
/**
/**
* 获取 开始 持续时间,单位毫秒
* 获取 开始 请求时间
* @return durationStart
* @return requestTimeStart
*/
*/
public
Integer
getDurationStart
(){
public
String
getRequestTimeStart
(){
return
this
.
requestTimeStart
;
}
/**
* 设置 开始 请求时间
* @param requestTimeStart
*/
public
void
setRequestTimeStart
(
String
requestTimeStart
){
this
.
requestTimeStart
=
requestTimeStart
;
}
/**
* 获取 结束 请求时间
* @return requestTimeEnd
*/
public
String
getRequestTimeEnd
(){
return
this
.
requestTimeEnd
;
}
/**
* 设置 结束 请求时间
* @param requestTimeEnd
*/
public
void
setRequestTimeEnd
(
String
requestTimeEnd
){
this
.
requestTimeEnd
=
requestTimeEnd
;
}
/**
* 获取 开始 响应时间
* @return responseTimeStart
*/
public
String
getResponseTimeStart
(){
return
this
.
responseTimeStart
;
}
/**
* 设置 开始 响应时间
* @param responseTimeStart
*/
public
void
setResponseTimeStart
(
String
responseTimeStart
){
this
.
responseTimeStart
=
responseTimeStart
;
}
/**
* 获取 结束 响应时间
* @return responseTimeEnd
*/
public
String
getResponseTimeEnd
(){
return
this
.
responseTimeEnd
;
}
/**
* 设置 结束 响应时间
* @param responseTimeEnd
*/
public
void
setResponseTimeEnd
(
String
responseTimeEnd
){
this
.
responseTimeEnd
=
responseTimeEnd
;
}
/**
* 获取 开始 持续时间,单位毫秒
* @return durationStart
*/
public
Long
getDurationStart
(){
return
this
.
durationStart
;
return
this
.
durationStart
;
}
}
/**
/**
* 设置 开始 持续时间,单位毫秒
* 设置 开始 持续时间,单位毫秒
* @param durationStart
* @param durationStart
*/
*/
public
void
setDurationStart
(
Integer
durationStart
){
public
void
setDurationStart
(
Long
durationStart
){
this
.
durationStart
=
durationStart
;
this
.
durationStart
=
durationStart
;
}
}
/**
/**
* 获取 结束 持续时间,单位毫秒
* 获取 结束 持续时间,单位毫秒
* @return $durationEnd
* @return $durationEnd
*/
*/
public
Integer
getDurationEnd
(){
public
Long
getDurationEnd
(){
return
this
.
durationEnd
;
return
this
.
durationEnd
;
}
}
/**
/**
* 设置 结束 持续时间,单位毫秒
* 设置 结束 持续时间,单位毫秒
* @param durationEnd
* @param durationEnd
*/
*/
public
void
setDurationEnd
(
Integer
durationEnd
){
public
void
setDurationEnd
(
Long
durationEnd
){
this
.
durationEnd
=
durationEnd
;
this
.
durationEnd
=
durationEnd
;
}
}
/**
/**
* 获取 增加 持续时间,单位毫秒
* 获取 增加 持续时间,单位毫秒
* @return durationIncrement
* @return durationIncrement
*/
*/
public
Integer
getDurationIncrement
(){
public
Long
getDurationIncrement
(){
return
this
.
durationIncrement
;
return
this
.
durationIncrement
;
}
}
/**
/**
* 设置 增加 持续时间,单位毫秒
* 设置 增加 持续时间,单位毫秒
* @param durationIncrement
* @param durationIncrement
*/
*/
public
void
setDurationIncrement
(
Integer
durationIncrement
){
public
void
setDurationIncrement
(
Long
durationIncrement
){
this
.
durationIncrement
=
durationIncrement
;
this
.
durationIncrement
=
durationIncrement
;
}
}
/**
/**
* 获取 持续时间,单位毫秒
* 获取 持续时间,单位毫秒
* @return durationList
* @return durationList
*/
*/
public
List
<
Integer
>
getDurationList
(){
public
List
<
Long
>
getDurationList
(){
return
this
.
durationList
;
return
this
.
durationList
;
}
}
/**
/**
* 设置 持续时间,单位毫秒
* 设置 持续时间,单位毫秒
* @param durationList
* @param durationList
*/
*/
public
void
setDurationList
(
List
<
Integer
>
durationList
){
public
void
setDurationList
(
List
<
Long
>
durationList
){
this
.
durationList
=
durationList
;
this
.
durationList
=
durationList
;
}
}
/**
/**
* 获取 开始 创建用户
* 获取 开始 创建用户
* @return createUserIdStart
* @return createUserIdStart
*/
*/
public
Long
getCreateUserIdStart
(){
public
Long
getCreateUserIdStart
(){
return
this
.
createUserIdStart
;
return
this
.
createUserIdStart
;
}
}
/**
/**
* 设置 开始 创建用户
* 设置 开始 创建用户
* @param createUserIdStart
* @param createUserIdStart
*/
*/
public
void
setCreateUserIdStart
(
Long
createUserIdStart
){
public
void
setCreateUserIdStart
(
Long
createUserIdStart
){
this
.
createUserIdStart
=
createUserIdStart
;
this
.
createUserIdStart
=
createUserIdStart
;
}
}
/**
/**
* 获取 结束 创建用户
* 获取 结束 创建用户
* @return $createUserIdEnd
* @return $createUserIdEnd
*/
*/
public
Long
getCreateUserIdEnd
(){
public
Long
getCreateUserIdEnd
(){
return
this
.
createUserIdEnd
;
return
this
.
createUserIdEnd
;
}
}
/**
/**
* 设置 结束 创建用户
* 设置 结束 创建用户
* @param createUserIdEnd
* @param createUserIdEnd
*/
*/
public
void
setCreateUserIdEnd
(
Long
createUserIdEnd
){
public
void
setCreateUserIdEnd
(
Long
createUserIdEnd
){
this
.
createUserIdEnd
=
createUserIdEnd
;
this
.
createUserIdEnd
=
createUserIdEnd
;
}
}
/**
/**
* 获取 增加 创建用户
* 获取 增加 创建用户
* @return createUserIdIncrement
* @return createUserIdIncrement
*/
*/
public
Long
getCreateUserIdIncrement
(){
public
Long
getCreateUserIdIncrement
(){
return
this
.
createUserIdIncrement
;
return
this
.
createUserIdIncrement
;
}
}
/**
/**
* 设置 增加 创建用户
* 设置 增加 创建用户
* @param createUserIdIncrement
* @param createUserIdIncrement
*/
*/
public
void
setCreateUserIdIncrement
(
Long
createUserIdIncrement
){
public
void
setCreateUserIdIncrement
(
Long
createUserIdIncrement
){
this
.
createUserIdIncrement
=
createUserIdIncrement
;
this
.
createUserIdIncrement
=
createUserIdIncrement
;
}
}
/**
/**
* 获取 创建用户
* 获取 创建用户
* @return createUserIdList
* @return createUserIdList
*/
*/
public
List
<
Long
>
getCreateUserIdList
(){
public
List
<
Long
>
getCreateUserIdList
(){
return
this
.
createUserIdList
;
return
this
.
createUserIdList
;
}
}
/**
/**
* 设置 创建用户
* 设置 创建用户
* @param createUserIdList
* @param createUserIdList
*/
*/
public
void
setCreateUserIdList
(
List
<
Long
>
createUserIdList
){
public
void
setCreateUserIdList
(
List
<
Long
>
createUserIdList
){
this
.
createUserIdList
=
createUserIdList
;
this
.
createUserIdList
=
createUserIdList
;
}
}
/**
/**
* 获取 开始 创建时间
* 获取 开始 创建时间
* @return createTimeStart
* @return createTimeStart
*/
*/
public
String
getCreateTimeStart
(){
public
String
getCreateTimeStart
(){
return
this
.
createTimeStart
;
return
this
.
createTimeStart
;
}
}
/**
/**
* 设置 开始 创建时间
* 设置 开始 创建时间
* @param createTimeStart
* @param createTimeStart
*/
*/
public
void
setCreateTimeStart
(
String
createTimeStart
){
public
void
setCreateTimeStart
(
String
createTimeStart
){
this
.
createTimeStart
=
createTimeStart
;
this
.
createTimeStart
=
createTimeStart
;
}
}
/**
/**
* 获取 结束 创建时间
* 获取 结束 创建时间
* @return createTimeEnd
* @return createTimeEnd
*/
*/
public
String
getCreateTimeEnd
(){
public
String
getCreateTimeEnd
(){
return
this
.
createTimeEnd
;
return
this
.
createTimeEnd
;
}
}
/**
/**
* 设置 结束 创建时间
* 设置 结束 创建时间
* @param createTimeEnd
* @param createTimeEnd
*/
*/
public
void
setCreateTimeEnd
(
String
createTimeEnd
){
public
void
setCreateTimeEnd
(
String
createTimeEnd
){
this
.
createTimeEnd
=
createTimeEnd
;
this
.
createTimeEnd
=
createTimeEnd
;
}
}
/**
/**
* 设置 主键ID,主键,自增长
* 设置 主键ID
* @param id
* @param id
*/
*/
public
AccessLogPdu
id
(
Long
id
){
public
AccessLogPdu
id
(
Long
id
){
setId
(
id
);
setId
(
id
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 开始 主键ID,主键,自增长
* 设置 开始 主键ID
* @param idStart
* @param idStart
*/
*/
public
AccessLogPdu
idStart
(
Long
idStart
){
public
AccessLogPdu
idStart
(
Long
idStart
){
this
.
idStart
=
idStart
;
this
.
idStart
=
idStart
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 结束 主键ID,主键,自增长
* 设置 结束 主键ID
* @param idEnd
* @param idEnd
*/
*/
public
AccessLogPdu
idEnd
(
Long
idEnd
){
public
AccessLogPdu
idEnd
(
Long
idEnd
){
this
.
idEnd
=
idEnd
;
this
.
idEnd
=
idEnd
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 增加 主键ID,主键,自增长
* 设置 增加 主键ID
* @param idIncrement
* @param idIncrement
*/
*/
public
AccessLogPdu
idIncrement
(
Long
idIncrement
){
public
AccessLogPdu
idIncrement
(
Long
idIncrement
){
this
.
idIncrement
=
idIncrement
;
this
.
idIncrement
=
idIncrement
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 主键ID,主键,自增长
* 设置 主键ID
* @param idList
* @param idList
*/
*/
public
AccessLogPdu
idList
(
List
<
Long
>
idList
){
public
AccessLogPdu
idList
(
List
<
Long
>
idList
){
this
.
idList
=
idList
;
this
.
idList
=
idList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 追踪
Id
* 设置 Trace
Id
* @param traceID
* @param traceID
*/
*/
public
AccessLogPdu
traceID
(
String
traceID
){
public
AccessLogPdu
traceID
(
String
traceID
){
setTraceID
(
traceID
);
setTraceID
(
traceID
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 追踪
Id
* 设置 Trace
Id
* @param traceIDList
* @param traceIDList
*/
*/
public
AccessLogPdu
traceIDList
(
List
<
String
>
traceIDList
){
public
AccessLogPdu
traceIDList
(
List
<
String
>
traceIDList
){
this
.
traceIDList
=
traceIDList
;
this
.
traceIDList
=
traceIDList
;
return
this
;
return
this
;
}
/**
* 设置 父服务调用id
* @param pspanId
*/
public
AccessLogPdu
pspanId
(
Integer
pspanId
){
setPspanId
(
pspanId
);
return
this
;
}
/**
* 设置 开始 父服务调用id
* @param pspanIdStart
*/
public
AccessLogPdu
pspanIdStart
(
Integer
pspanIdStart
){
this
.
pspanIdStart
=
pspanIdStart
;
return
this
;
}
/**
* 设置 结束 父服务调用id
* @param pspanIdEnd
*/
public
AccessLogPdu
pspanIdEnd
(
Integer
pspanIdEnd
){
this
.
pspanIdEnd
=
pspanIdEnd
;
return
this
;
}
/**
* 设置 增加 父服务调用id
* @param pspanIdIncrement
*/
public
AccessLogPdu
pspanIdIncrement
(
Integer
pspanIdIncrement
){
this
.
pspanIdIncrement
=
pspanIdIncrement
;
return
this
;
}
/**
* 设置 父服务调用id
* @param pspanIdList
*/
public
AccessLogPdu
pspanIdList
(
List
<
Integer
>
pspanIdList
){
this
.
pspanIdList
=
pspanIdList
;
return
this
;
}
/**
* 设置 当前服务跨度Id
* @param spanId
*/
public
AccessLogPdu
spanId
(
Integer
spanId
){
setSpanId
(
spanId
);
return
this
;
}
/**
* 设置 开始 当前服务跨度Id
* @param spanIdStart
*/
public
AccessLogPdu
spanIdStart
(
Integer
spanIdStart
){
this
.
spanIdStart
=
spanIdStart
;
return
this
;
}
/**
* 设置 结束 当前服务跨度Id
* @param spanIdEnd
*/
public
AccessLogPdu
spanIdEnd
(
Integer
spanIdEnd
){
this
.
spanIdEnd
=
spanIdEnd
;
return
this
;
}
/**
* 设置 增加 当前服务跨度Id
* @param spanIdIncrement
*/
public
AccessLogPdu
spanIdIncrement
(
Integer
spanIdIncrement
){
this
.
spanIdIncrement
=
spanIdIncrement
;
return
this
;
}
/**
* 设置 当前服务跨度Id
* @param spanIdList
*/
public
AccessLogPdu
spanIdList
(
List
<
Integer
>
spanIdList
){
this
.
spanIdList
=
spanIdList
;
return
this
;
}
}
/**
/**
* 设置 应用名称
* 设置 应用名称
* @param appName
* @param appName
*/
*/
public
AccessLogPdu
appName
(
String
appName
){
public
AccessLogPdu
appName
(
String
appName
){
setAppName
(
appName
);
setAppName
(
appName
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 应用名称
* 设置 应用名称
* @param appNameList
* @param appNameList
*/
*/
public
AccessLogPdu
appNameList
(
List
<
String
>
appNameList
){
public
AccessLogPdu
appNameList
(
List
<
String
>
appNameList
){
this
.
appNameList
=
appNameList
;
this
.
appNameList
=
appNameList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 实例IP
* 设置 实例IP
* @param hostName
* @param hostName
*/
*/
public
AccessLogPdu
hostName
(
String
hostName
){
public
AccessLogPdu
hostName
(
String
hostName
){
setHostName
(
hostName
);
setHostName
(
hostName
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 实例IP
* 设置 实例IP
* @param hostNameList
* @param hostNameList
*/
*/
public
AccessLogPdu
hostNameList
(
List
<
String
>
hostNameList
){
public
AccessLogPdu
hostNameList
(
List
<
String
>
hostNameList
){
this
.
hostNameList
=
hostNameList
;
this
.
hostNameList
=
hostNameList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 日志等级
* 设置 目标服务
* @param logLevel
* @param targetServer
*/
*/
public
AccessLogPdu
targetServer
(
String
targetServer
){
setTargetServer
(
targetServer
);
return
this
;
}
/**
* 设置 目标服务
* @param targetServerList
*/
public
AccessLogPdu
targetServerList
(
List
<
String
>
targetServerList
){
this
.
targetServerList
=
targetServerList
;
return
this
;
}
/**
* 设置 日志等级
* @param logLevel
*/
public
AccessLogPdu
logLevel
(
String
logLevel
){
public
AccessLogPdu
logLevel
(
String
logLevel
){
setLogLevel
(
logLevel
);
setLogLevel
(
logLevel
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 日志等级
* 设置 日志等级
* @param logLevelList
* @param logLevelList
*/
*/
public
AccessLogPdu
logLevelList
(
List
<
String
>
logLevelList
){
public
AccessLogPdu
logLevelList
(
List
<
String
>
logLevelList
){
this
.
logLevelList
=
logLevelList
;
this
.
logLevelList
=
logLevelList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求者IP
* 设置 请求者IP
* @param requestIp
* @param requestIp
*/
*/
public
AccessLogPdu
requestIp
(
String
requestIp
){
public
AccessLogPdu
requestIp
(
String
requestIp
){
setRequestIp
(
requestIp
);
setRequestIp
(
requestIp
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求者IP
* 设置 请求者IP
* @param requestIpList
* @param requestIpList
*/
*/
public
AccessLogPdu
requestIpList
(
List
<
String
>
requestIpList
){
public
AccessLogPdu
requestIpList
(
List
<
String
>
requestIpList
){
this
.
requestIpList
=
requestIpList
;
this
.
requestIpList
=
requestIpList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求方式
* 设置 请求方式
* @param method
* @param method
*/
*/
public
AccessLogPdu
method
(
String
method
){
public
AccessLogPdu
method
(
String
method
){
setMethod
(
method
);
setMethod
(
method
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求方式
* 设置 请求方式
* @param methodList
* @param methodList
*/
*/
public
AccessLogPdu
methodList
(
List
<
String
>
methodList
){
public
AccessLogPdu
methodList
(
List
<
String
>
methodList
){
this
.
methodList
=
methodList
;
this
.
methodList
=
methodList
;
return
this
;
return
this
;
}
/**
* 设置 协议
* @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
* 设置 用户浏览器UA
* @param ua
* @param ua
*/
*/
public
AccessLogPdu
ua
(
String
ua
){
public
AccessLogPdu
ua
(
String
ua
){
setUa
(
ua
);
setUa
(
ua
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 用户浏览器UA
* 设置 用户浏览器UA
* @param uaList
* @param uaList
*/
*/
public
AccessLogPdu
uaList
(
List
<
String
>
uaList
){
public
AccessLogPdu
uaList
(
List
<
String
>
uaList
){
this
.
uaList
=
uaList
;
this
.
uaList
=
uaList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求URI
* 设置 请求URI
* @param uri
* @param uri
*/
*/
public
AccessLogPdu
uri
(
String
uri
){
public
AccessLogPdu
uri
(
String
uri
){
setUri
(
uri
);
setUri
(
uri
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求URI
* 设置 请求URI
* @param uriList
* @param uriList
*/
*/
public
AccessLogPdu
uriList
(
List
<
String
>
uriList
){
public
AccessLogPdu
uriList
(
List
<
String
>
uriList
){
this
.
uriList
=
uriList
;
this
.
uriList
=
uriList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求参数,json序列化
* 设置 请求参数,json序列化
* @param requestParam
* @param requestData
*/
*/
public
AccessLogPdu
request
Param
(
String
requestParam
){
public
AccessLogPdu
request
Data
(
String
requestData
){
setRequest
Param
(
requestParam
);
setRequest
Data
(
requestData
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 请求参数,json序列化
* 设置 请求参数,json序列化
* @param requestParam
List
* @param requestData
List
*/
*/
public
AccessLogPdu
request
ParamList
(
List
<
String
>
requestParam
List
){
public
AccessLogPdu
request
DataList
(
List
<
String
>
requestData
List
){
this
.
request
ParamList
=
requestParam
List
;
this
.
request
DataList
=
requestData
List
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 响应结果
* 设置 响应结果,
* @param response
* @param responseData
*/
*/
public
AccessLogPdu
response
(
String
response
){
public
AccessLogPdu
response
Data
(
String
responseData
){
setResponse
(
response
);
setResponse
Data
(
responseData
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 响应结果
* 设置 响应结果,
* @param response
List
* @param responseData
List
*/
*/
public
AccessLogPdu
response
List
(
List
<
String
>
response
List
){
public
AccessLogPdu
response
DataList
(
List
<
String
>
responseData
List
){
this
.
response
List
=
response
List
;
this
.
response
DataList
=
responseData
List
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 持续时间,单位毫秒
* 设置 持续时间,单位毫秒
* @param duration
* @param duration
*/
*/
public
AccessLogPdu
duration
(
Integer
duration
){
public
AccessLogPdu
duration
(
Long
duration
){
setDuration
(
duration
);
setDuration
(
duration
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 开始 持续时间,单位毫秒
* 设置 开始 持续时间,单位毫秒
* @param durationStart
* @param durationStart
*/
*/
public
AccessLogPdu
durationStart
(
Integer
durationStart
){
public
AccessLogPdu
durationStart
(
Long
durationStart
){
this
.
durationStart
=
durationStart
;
this
.
durationStart
=
durationStart
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 结束 持续时间,单位毫秒
* 设置 结束 持续时间,单位毫秒
* @param durationEnd
* @param durationEnd
*/
*/
public
AccessLogPdu
durationEnd
(
Integer
durationEnd
){
public
AccessLogPdu
durationEnd
(
Long
durationEnd
){
this
.
durationEnd
=
durationEnd
;
this
.
durationEnd
=
durationEnd
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 增加 持续时间,单位毫秒
* 设置 增加 持续时间,单位毫秒
* @param durationIncrement
* @param durationIncrement
*/
*/
public
AccessLogPdu
durationIncrement
(
Integer
durationIncrement
){
public
AccessLogPdu
durationIncrement
(
Long
durationIncrement
){
this
.
durationIncrement
=
durationIncrement
;
this
.
durationIncrement
=
durationIncrement
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 持续时间,单位毫秒
* 设置 持续时间,单位毫秒
* @param durationList
* @param durationList
*/
*/
public
AccessLogPdu
durationList
(
List
<
Integer
>
durationList
){
public
AccessLogPdu
durationList
(
List
<
Long
>
durationList
){
this
.
durationList
=
durationList
;
this
.
durationList
=
durationList
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 创建用户
* 设置 创建用户
* @param createUserId
* @param createUserId
*/
*/
public
AccessLogPdu
createUserId
(
Long
createUserId
){
public
AccessLogPdu
createUserId
(
Long
createUserId
){
setCreateUserId
(
createUserId
);
setCreateUserId
(
createUserId
);
return
this
;
return
this
;
}
}
/**
/**
* 设置 开始 创建用户
* 设置 开始 创建用户
* @param createUserIdStart
* @param createUserIdStart
*/
*/
public
AccessLogPdu
createUserIdStart
(
Long
createUserIdStart
){
public
AccessLogPdu
createUserIdStart
(
Long
createUserIdStart
){
this
.
createUserIdStart
=
createUserIdStart
;
this
.
createUserIdStart
=
createUserIdStart
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 结束 创建用户
* 设置 结束 创建用户
* @param createUserIdEnd
* @param createUserIdEnd
*/
*/
public
AccessLogPdu
createUserIdEnd
(
Long
createUserIdEnd
){
public
AccessLogPdu
createUserIdEnd
(
Long
createUserIdEnd
){
this
.
createUserIdEnd
=
createUserIdEnd
;
this
.
createUserIdEnd
=
createUserIdEnd
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 增加 创建用户
* 设置 增加 创建用户
* @param createUserIdIncrement
* @param createUserIdIncrement
*/
*/
public
AccessLogPdu
createUserIdIncrement
(
Long
createUserIdIncrement
){
public
AccessLogPdu
createUserIdIncrement
(
Long
createUserIdIncrement
){
this
.
createUserIdIncrement
=
createUserIdIncrement
;
this
.
createUserIdIncrement
=
createUserIdIncrement
;
return
this
;
return
this
;
}
}
/**
/**
* 设置 创建用户
* 设置 创建用户
* @param createUserIdList
* @param createUserIdList
*/
*/
public
AccessLogPdu
createUserIdList
(
List
<
Long
>
createUserIdList
){
public
AccessLogPdu
createUserIdList
(
List
<
Long
>
createUserIdList
){
this
.
createUserIdList
=
createUserIdList
;
this
.
createUserIdList
=
createUserIdList
;
return
this
;
return
this
;
}
}
/**
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
* @return orConditionList
*/
*/
public
List
<
AccessLogPdu
>
getOrConditionList
(){
public
List
<
AccessLogPdu
>
getOrConditionList
(){
return
this
.
orConditionList
;
return
this
.
orConditionList
;
}
}
/**
/**
* 设置 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* 设置 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @param orConditionList
* @param orConditionList
*/
*/
public
void
setOrConditionList
(
List
<
AccessLogPdu
>
orConditionList
){
public
void
setOrConditionList
(
List
<
AccessLogPdu
>
orConditionList
){
this
.
orConditionList
=
orConditionList
;
this
.
orConditionList
=
orConditionList
;
}
}
/**
/**
* 获取 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* 获取 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* @return andConditionList
* @return andConditionList
*/
*/
public
List
<
AccessLogPdu
>
getAndConditionList
(){
public
List
<
AccessLogPdu
>
getAndConditionList
(){
return
this
.
andConditionList
;
return
this
.
andConditionList
;
}
}
/**
/**
* 设置 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* 设置 AND条件集合,列表项之间是AND,项内容之间是OR,如:(list[0].1 or list[0].2) and (list[1].3 or list[1].4)
* @param andConditionList
* @param andConditionList
*/
*/
public
void
setAndConditionList
(
List
<
AccessLogPdu
>
andConditionList
){
public
void
setAndConditionList
(
List
<
AccessLogPdu
>
andConditionList
){
this
.
andConditionList
=
andConditionList
;
this
.
andConditionList
=
andConditionList
;
}
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
this
.
getId
().
hashCode
();
return
this
.
getId
().
hashCode
();
}
}
@Override
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
obj
)
{
...
@@ -1095,7 +1595,7 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -1095,7 +1595,7 @@ public class AccessLogPdu extends BaseEntityLong {
if
(
obj
instanceof
AccessLogPdu
)
{
if
(
obj
instanceof
AccessLogPdu
)
{
AccessLogPdu
tmp
=
(
AccessLogPdu
)
obj
;
AccessLogPdu
tmp
=
(
AccessLogPdu
)
obj
;
if
(
this
.
getId
()
==
tmp
.
getId
())
{
if
(
this
.
getId
()
==
tmp
.
getId
())
{
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
...
@@ -1103,28 +1603,40 @@ public class AccessLogPdu extends BaseEntityLong {
...
@@ -1103,28 +1603,40 @@ public class AccessLogPdu extends BaseEntityLong {
public
void
initAttrValue
(){
public
void
initAttrValue
(){
this
.
traceID
=
""
;
this
.
traceID
=
""
;
this
.
pspanId
=
0
;
this
.
spanId
=
null
;
this
.
appName
=
""
;
this
.
hostName
=
""
;
this
.
targetServer
=
""
;
this
.
logLevel
=
"INFO"
;
this
.
appName
=
""
;
this
.
requestIp
=
""
;
this
.
hostName
=
""
;
this
.
method
=
""
;
this
.
logLevel
=
"
"
;
this
.
schema
=
"http
"
;
this
.
requestIp
=
""
;
this
.
ua
=
""
;
this
.
method
=
""
;
this
.
uri
=
""
;
this
.
u
a
=
""
;
this
.
requestDat
a
=
""
;
this
.
uri
=
""
;
this
.
responseData
=
""
;
this
.
requestParam
=
""
;
this
.
logTime
=
null
;
this
.
response
=
""
;
this
.
requestTime
=
null
;
this
.
log
Time
=
null
;
this
.
response
Time
=
null
;
this
.
duration
=
null
;
this
.
duration
=
null
;
}
}
}
}
\ No newline at end of file
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/AccessLogFilter.java
0 → 100644
View file @
db8a61d7
package
com.mortals.xhx.base.framework.filter
;
import
cn.hutool.core.net.NetUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.framework.service.MessageProducer
;
import
com.mortals.xhx.common.pdu.access.AccessLogPdu
;
import
com.mortals.xhx.common.utils.IpUtils
;
import
jodd.util.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.reactivestreams.Publisher
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutputMessage
;
import
org.springframework.cloud.gateway.route.Route
;
import
org.springframework.cloud.gateway.support.BodyInserterContext
;
import
org.springframework.cloud.gateway.support.ServerWebExchangeUtils
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.core.io.buffer.DataBufferFactory
;
import
org.springframework.core.io.buffer.DataBufferUtils
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpRequestDecorator
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.http.server.reactive.ServerHttpResponseDecorator
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.reactive.function.BodyInserter
;
import
org.springframework.web.reactive.function.BodyInserters
;
import
org.springframework.web.reactive.function.server.HandlerStrategies
;
import
org.springframework.web.reactive.function.server.ServerRequest
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.util.WebUtils
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author: zxfei
* @date: 2022/8/18 23:52
* @description:
**/
@Slf4j
@Component
public
class
AccessLogFilter
implements
GlobalFilter
,
Ordered
{
// @Autowired
// private AccessLogService accessLogService;
@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"
;
private
final
List
<
HttpMessageReader
<?>>
messageReaders
=
HandlerStrategies
.
withDefaults
().
messageReaders
();
/**
* 顺序必须是<-1,否则标准的NettyWriteResponseFilter将在您的过滤器得到一个被调用的机会之前发送响应
* 也就是说如果不小于 -1 ,将不会执行获取后端响应的逻辑
*
* @return
*/
@Override
public
int
getOrder
()
{
return
-
2
;
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
ServerHttpRequest
request
=
exchange
.
getRequest
();
// 请求路径
String
requestPath
=
request
.
getPath
().
pathWithinApplication
().
value
();
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
.
setHostName
(
NetUtil
.
getLocalHostName
());
accessLogPdu
.
setUri
(
requestPath
);
accessLogPdu
.
setTargetServer
(
route
.
getId
());
accessLogPdu
.
setRequestIp
(
IpUtils
.
getRealIpAddress
(
exchange
.
getRequest
()));
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
);
}
else
{
return
writeBasicLog
(
exchange
,
chain
,
accessLogPdu
);
}
}
/**
* form参数形式
*
* @param exchange
* @param chain
* @param accessLog
* @return
*/
private
Mono
<
Void
>
writeBasicLog
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
,
AccessLogPdu
accessLog
)
{
StringBuilder
builder
=
new
StringBuilder
();
MultiValueMap
<
String
,
String
>
queryParams
=
exchange
.
getRequest
().
getQueryParams
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
queryParams
.
entrySet
())
{
builder
.
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
StringUtils
.
join
(
entry
.
getValue
(),
","
));
}
accessLog
.
setRequestData
(
builder
.
toString
());
//获取响应体
ServerHttpResponseDecorator
decoratedResponse
=
recordResponseLog
(
exchange
,
accessLog
);
return
chain
.
filter
(
exchange
.
mutate
().
response
(
decoratedResponse
).
build
())
.
then
(
Mono
.
fromRunnable
(()
->
{
// 打印日志 发送
writeAccessLog
(
accessLog
);
}));
}
/**
* 解决 request body 只能读取一次问题,
* 参考: org.springframework.cloud.gateway.filter.factory.rewrite.ModifyRequestBodyGatewayFilterFactory
*
* @param exchange
* @param chain
* @param accessLogPdu
* @return
*/
@SuppressWarnings
(
"unchecked"
)
private
Mono
writeBodyLog
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
,
AccessLogPdu
accessLogPdu
)
{
ServerRequest
serverRequest
=
ServerRequest
.
create
(
exchange
,
messageReaders
);
Mono
<
String
>
modifiedBody
=
serverRequest
.
bodyToMono
(
String
.
class
)
.
flatMap
(
body
->
{
accessLogPdu
.
setRequestData
(
body
);
return
Mono
.
just
(
body
);
});
// 通过 BodyInserter 插入 body(支持修改body), 避免 request body 只能获取一次
BodyInserter
bodyInserter
=
BodyInserters
.
fromPublisher
(
modifiedBody
,
String
.
class
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
putAll
(
exchange
.
getRequest
().
getHeaders
());
// the new content type will be computed by bodyInserter
// and then set in the request decorator
headers
.
remove
(
HttpHeaders
.
CONTENT_LENGTH
);
CachedBodyOutputMessage
outputMessage
=
new
CachedBodyOutputMessage
(
exchange
,
headers
);
return
bodyInserter
.
insert
(
outputMessage
,
new
BodyInserterContext
())
.
then
(
Mono
.
defer
(()
->
{
// 重新封装请求
ServerHttpRequest
decoratedRequest
=
requestDecorate
(
exchange
,
headers
,
outputMessage
);
// 记录响应日志
ServerHttpResponseDecorator
decoratedResponse
=
recordResponseLog
(
exchange
,
accessLogPdu
);
// 记录普通的
return
chain
.
filter
(
exchange
.
mutate
().
request
(
decoratedRequest
).
response
(
decoratedResponse
).
build
())
.
then
(
Mono
.
fromRunnable
(()
->
{
// 打印日志 并发送
writeAccessLog
(
accessLogPdu
);
}));
}));
}
private
void
writeAccessLog
(
AccessLogPdu
accessLogPdu
)
{
// log.info("accessLog:{}",JSON.toJSONString(accessLogPdu));
messageProducer
.
syncAccessSend
(
accessLogPdu
);
}
private
Route
getGatewayRoute
(
ServerWebExchange
exchange
)
{
return
exchange
.
getAttribute
(
ServerWebExchangeUtils
.
GATEWAY_ROUTE_ATTR
);
}
/**
* 请求装饰器,重新计算 headers
*
* @param exchange
* @param headers
* @param outputMessage
* @return
*/
private
ServerHttpRequestDecorator
requestDecorate
(
ServerWebExchange
exchange
,
HttpHeaders
headers
,
CachedBodyOutputMessage
outputMessage
)
{
return
new
ServerHttpRequestDecorator
(
exchange
.
getRequest
())
{
@Override
public
HttpHeaders
getHeaders
()
{
long
contentLength
=
headers
.
getContentLength
();
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
putAll
(
super
.
getHeaders
());
if
(
contentLength
>
0
)
{
httpHeaders
.
setContentLength
(
contentLength
);
}
else
{
// TODO: this causes a 'HTTP/1.1 411 Length Required' // on
// httpbin.org
httpHeaders
.
set
(
HttpHeaders
.
TRANSFER_ENCODING
,
"chunked"
);
}
return
httpHeaders
;
}
@Override
public
Flux
<
DataBuffer
>
getBody
()
{
return
outputMessage
.
getBody
();
}
};
}
/**
* 记录响应日志
* 通过 DataBufferFactory 解决响应体分段传输问题。
*/
private
ServerHttpResponseDecorator
recordResponseLog
(
ServerWebExchange
exchange
,
AccessLogPdu
accessLogPdu
)
{
ServerHttpResponse
response
=
exchange
.
getResponse
();
DataBufferFactory
bufferFactory
=
response
.
bufferFactory
();
return
new
ServerHttpResponseDecorator
(
response
)
{
@Override
public
Mono
<
Void
>
writeWith
(
Publisher
<?
extends
DataBuffer
>
body
)
{
if
(
body
instanceof
Flux
)
{
Date
responseTime
=
new
Date
();
// accessLogPdu.setResponseTime(responseTime);
// 计算执行时间
long
executeTime
=
(
responseTime
.
getTime
()
-
accessLogPdu
.
getRequestTime
().
getTime
());
accessLogPdu
.
setDuration
(
executeTime
);
// 获取响应类型,如果是 json 就打印
String
originalResponseContentType
=
exchange
.
getAttribute
(
ServerWebExchangeUtils
.
ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR
);
if
(
ObjectUtil
.
equal
(
this
.
getStatusCode
(),
HttpStatus
.
OK
)
&&
StringUtil
.
isNotBlank
(
originalResponseContentType
)
&&
originalResponseContentType
.
contains
(
"application/json"
))
{
Flux
<?
extends
DataBuffer
>
fluxBody
=
Flux
.
from
(
body
);
return
super
.
writeWith
(
fluxBody
.
buffer
().
map
(
dataBuffers
->
{
// 合并多个流集合,解决返回体分段传输
DataBufferFactory
dataBufferFactory
=
new
DefaultDataBufferFactory
();
DataBuffer
join
=
dataBufferFactory
.
join
(
dataBuffers
);
byte
[]
content
=
new
byte
[
join
.
readableByteCount
()];
join
.
read
(
content
);
// 释放掉内存
DataBufferUtils
.
release
(
join
);
String
responseResult
=
new
String
(
content
,
StandardCharsets
.
UTF_8
);
accessLogPdu
.
setResponseData
(
responseResult
);
return
bufferFactory
.
wrap
(
content
);
}));
}
}
// if body is not a flux. never got there.
return
super
.
writeWith
(
body
);
}
};
}
}
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
View file @
db8a61d7
...
@@ -39,7 +39,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.O
...
@@ -39,7 +39,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.O
* @date: 2022/8/18 13:48
* @date: 2022/8/18 13:48
* @description:
* @description:
**/
**/
@Component
//
@Component
@Slf4j
@Slf4j
public
class
GatewayResponseFilter
implements
GlobalFilter
,
Ordered
{
public
class
GatewayResponseFilter
implements
GlobalFilter
,
Ordered
{
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalCacheRequestFilter.java
View file @
db8a61d7
...
@@ -21,7 +21,7 @@ import reactor.core.publisher.Mono;
...
@@ -21,7 +21,7 @@ import reactor.core.publisher.Mono;
* @author: zxfei
* @author: zxfei
* @date: 2022/6/20 16:59
* @date: 2022/6/20 16:59
*/
*/
@Component
//
@Component
@Slf4j
@Slf4j
public
class
GlobalCacheRequestFilter
implements
GlobalFilter
,
Ordered
{
public
class
GlobalCacheRequestFilter
implements
GlobalFilter
,
Ordered
{
...
@@ -51,6 +51,6 @@ public class GlobalCacheRequestFilter implements GlobalFilter, Ordered {
...
@@ -51,6 +51,6 @@ public class GlobalCacheRequestFilter implements GlobalFilter, Ordered {
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
HIGHEST_PRECEDENCE
;
return
-
3
;
}
}
}
}
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalLogFilter.java
View file @
db8a61d7
...
@@ -61,57 +61,63 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
...
@@ -61,57 +61,63 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
private
static
final
String
START_TIME
=
"startTime"
;
private
static
final
String
START_TIME
=
"startTime"
;
private
static
final
String
TRACE_ID
=
"traceId"
;
private
static
final
String
TRACE_ID
=
"traceId"
;
private
static
final
String
SPAN_ID
=
"spanId"
;
private
static
final
String
PSPAN_ID
=
"pspanId"
;
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
log
.
info
(
"GlobalLogFilter:{}"
,
getOrder
());
log
.
info
(
"GlobalLogFilter:{}"
,
getOrder
());
MDC
.
put
(
"startTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
//保存请求链路,设置数据追踪id到header中
//保存请求链路,设置数据追踪id到header中
Integer
pspanId
=
0
;
if
(!
customGatewayProperties
.
getRequestLog
())
{
Integer
spanId
=
1
;
return
chain
.
filter
(
exchange
);
}
ServerHttpRequest
request
=
exchange
.
getRequest
();
String
path
=
request
.
getPath
().
toString
();
String
method
=
request
.
getMethod
().
name
();
//判断请求类型
String
paramStr
=
""
;
if
(
isJsonRequest
(
request
))
{
//读取请求体后 内容需要重新设置进去
paramStr
=
resolveBodyFromRequest
(
request
);
}
else
{
//非json类型,
MultiValueMap
<
String
,
String
>
parameterMap
=
request
.
getQueryParams
();
paramStr
=
JSON
.
toJSONString
(
parameterMap
);
}
String
traceId
=
IdUtil
.
objectId
();
String
traceId
=
IdUtil
.
objectId
();
AccessLogPdu
accessLogPdu
=
new
AccessLogPdu
();
accessLogPdu
.
initAttrValue
();
accessLogPdu
.
setAppName
(
appName
);
accessLogPdu
.
setHostName
(
NetUtil
.
getLocalHostName
());
accessLogPdu
.
setLogLevel
(
"INFO"
);
accessLogPdu
.
setRequestIp
(
IpUtils
.
getRealIpAddress
(
exchange
.
getRequest
()));
accessLogPdu
.
setRequestParam
(
paramStr
);
accessLogPdu
.
setLogTime
(
new
Date
());
accessLogPdu
.
setMethod
(
method
);
accessLogPdu
.
setUri
(
path
);
accessLogPdu
.
setTraceID
(
traceId
);
messageProducer
.
syncAccessSend
(
accessLogPdu
);
exchange
.
getAttributes
().
put
(
START_TIME
,
System
.
currentTimeMillis
());
ServerHttpRequest
newRequest
=
exchange
.
getRequest
().
mutate
()
ServerHttpRequest
newRequest
=
exchange
.
getRequest
().
mutate
()
.
header
(
TRACE_ID
,
traceId
)
.
header
(
TRACE_ID
,
traceId
)
.
header
(
SPAN_ID
,
pspanId
.
toString
())
.
header
(
PSPAN_ID
,
spanId
.
toString
())
.
build
();
.
build
();
return
chain
.
filter
(
exchange
.
mutate
().
request
(
newRequest
).
build
());
return
chain
.
filter
(
exchange
.
mutate
().
request
(
newRequest
).
build
());
//判断请求类型
// String paramStr ="";
// if (isJsonRequest(request)) {
// //读取请求体后 内容需要重新设置进去
// paramStr = resolveBodyFromRequest(request);
// } else {
// //非json类型,
// MultiValueMap<String, String> parameterMap = request.getQueryParams();
// paramStr=JSON.toJSONString(parameterMap);
// }
// AccessLogPdu accessLogPdu = new AccessLogPdu();
// accessLogPdu.initAttrValue();
// accessLogPdu.setAppName(appName);
// accessLogPdu.setHostName(NetUtil.getLocalHostName());
// accessLogPdu.setLogLevel("INFO");
// accessLogPdu.setRequestIp(IpUtils.getRealIpAddress(exchange.getRequest()));
// accessLogPdu.setRequestData(paramStr);
// accessLogPdu.setLogTime(new Date());
// accessLogPdu.setMethod(method);
// accessLogPdu.setUri(path);
// accessLogPdu.setTraceID(traceId);
// messageProducer.syncAccessSend(accessLogPdu);
//exchange.getAttributes().put(START_TIME, System.currentTimeMillis());
// ServerHttpRequest newRequest = exchange.getRequest().mutate()
// .header(TRACE_ID, traceId)
// .header(TRACE_ID, traceId)
// .header(TRACE_ID, traceId)
// .build();
//
// return chain.filter(exchange.mutate().request(newRequest).build());
}
}
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
0
;
return
-
3
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment