...
|
...
|
@@ -4,8 +4,11 @@ import javax.annotation.PostConstruct; |
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.yoho.search.common.utils.HttpServletRequestUtils;
|
|
|
import com.yoho.search.service.base.SearchDynamicConfigService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.NamedThreadLocal;
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
...
|
...
|
@@ -30,6 +33,9 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
|
|
|
|
|
private PerformanceMonitor monitor;
|
|
|
|
|
|
@Autowired
|
|
|
private SearchDynamicConfigService searchDynamicConfigService;
|
|
|
|
|
|
@PostConstruct
|
|
|
void init() {
|
|
|
monitor = new PerformanceMonitor("CONTROLLER_PERFORMANCE", CONTROLLER_PERFORMANCE, 10);
|
...
|
...
|
@@ -66,8 +72,11 @@ public class ControllerCostInterceptor implements HandlerInterceptor { |
|
|
if (cost <= 500) {
|
|
|
return;
|
|
|
}
|
|
|
// // 5、打印响应超过500ms的请求与参数
|
|
|
// CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request));
|
|
|
|
|
|
// 5、打印响应超过500ms的请求与参数
|
|
|
if(searchDynamicConfigService.isControllerCostLogOpen()){
|
|
|
CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
} finally {
|
...
|
...
|
|