|
@@ -4,8 +4,11 @@ import javax.annotation.PostConstruct; |
|
@@ -4,8 +4,11 @@ import javax.annotation.PostConstruct; |
4
|
import javax.servlet.http.HttpServletRequest;
|
4
|
import javax.servlet.http.HttpServletRequest;
|
5
|
import javax.servlet.http.HttpServletResponse;
|
5
|
import javax.servlet.http.HttpServletResponse;
|
6
|
|
6
|
|
|
|
7
|
+import com.yoho.search.common.utils.HttpServletRequestUtils;
|
|
|
8
|
+import com.yoho.search.service.base.SearchDynamicConfigService;
|
7
|
import org.slf4j.Logger;
|
9
|
import org.slf4j.Logger;
|
8
|
import org.slf4j.LoggerFactory;
|
10
|
import org.slf4j.LoggerFactory;
|
|
|
11
|
+import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.core.NamedThreadLocal;
|
12
|
import org.springframework.core.NamedThreadLocal;
|
10
|
import org.springframework.web.servlet.HandlerInterceptor;
|
13
|
import org.springframework.web.servlet.HandlerInterceptor;
|
11
|
import org.springframework.web.servlet.ModelAndView;
|
14
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -30,6 +33,9 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
|
@@ -30,6 +33,9 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
30
|
|
33
|
|
31
|
private PerformanceMonitor monitor;
|
34
|
private PerformanceMonitor monitor;
|
32
|
|
35
|
|
|
|
36
|
+ @Autowired
|
|
|
37
|
+ private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
38
|
+
|
33
|
@PostConstruct
|
39
|
@PostConstruct
|
34
|
void init() {
|
40
|
void init() {
|
35
|
monitor = new PerformanceMonitor("CONTROLLER_PERFORMANCE", CONTROLLER_PERFORMANCE, 10);
|
41
|
monitor = new PerformanceMonitor("CONTROLLER_PERFORMANCE", CONTROLLER_PERFORMANCE, 10);
|
|
@@ -66,8 +72,11 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
|
@@ -66,8 +72,11 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
66
|
if (cost <= 500) {
|
72
|
if (cost <= 500) {
|
67
|
return;
|
73
|
return;
|
68
|
}
|
74
|
}
|
69
|
- // // 5、打印响应超过500ms的请求与参数
|
|
|
70
|
- // CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request));
|
75
|
+
|
|
|
76
|
+ // 5、打印响应超过500ms的请求与参数
|
|
|
77
|
+ if(searchDynamicConfigService.isControllerCostLogOpen()){
|
|
|
78
|
+ CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request));
|
|
|
79
|
+ }
|
71
|
} catch (Exception e) {
|
80
|
} catch (Exception e) {
|
72
|
// TODO: handle exception
|
81
|
// TODO: handle exception
|
73
|
} finally {
|
82
|
} finally {
|