common-trace优化pom.xml中包引用
This commit is contained in:
parent
dd1827f8ce
commit
a191d19dce
@ -11,11 +11,6 @@
|
||||
<name>Axzo Common trace</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@ -41,16 +36,6 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
package com.axzo.framework.trace.interceptor;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.axzo.framework.trace.util.RequestUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 打印出入参及耗时
|
||||
*
|
||||
* @author TanJ
|
||||
* @date 2021/5/12
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RequestLog {
|
||||
|
||||
final String checkDeath = "checkDeath";
|
||||
|
||||
@Around("@within(restController)||@annotation(restController)||@within(feignClient)")
|
||||
@SneakyThrows
|
||||
public Object request(ProceedingJoinPoint joinPoint, RestController restController, FeignClient feignClient) {
|
||||
|
||||
HttpServletRequest request = RequestUtil.getRequest();
|
||||
|
||||
if (request == null) {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
if (request.getRequestURL().toString().contains(checkDeath)) {
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
Object proceed = joinPoint.proceed();
|
||||
stopWatch.stop();
|
||||
log.info("[response]返回记录:responseParam = {} latency = {}", JSONUtil.toJsonStr(proceed),
|
||||
stopWatch.getTotalTimeMillis());
|
||||
return proceed;
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ import java.nio.charset.Charset;
|
||||
* @date 2021/12/13 11:13
|
||||
*/
|
||||
@Slf4j
|
||||
@ConditionalOnProperty(prefix = "axzo.log.pokonya", name = "enable", havingValue = "true", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "axzo.log.common.trace", name = "enable", havingValue = "true", matchIfMissing = true)
|
||||
@Component
|
||||
public class RequestLogHandlerInterceptor implements HandlerInterceptor, WebMvcConfigurer {
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
* @date 2021/5/24
|
||||
*/
|
||||
@Slf4j
|
||||
//@ConditionalOnProperty(prefix = "axzo.log.pokonya", name = "enable", havingValue = "true", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "axzo.log.common.trace", name = "enable", havingValue = "true", matchIfMissing = true)
|
||||
@Component
|
||||
@Order(-99999)
|
||||
public class TraceIdFilter extends OncePerRequestFilter {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user