Authored by hugufei

超时统计添加开关

... ... @@ -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 {
... ...
... ... @@ -215,5 +215,12 @@ public class SearchDynamicConfigService {
public boolean isSearchLikeSimilarSknOpen() {
return configReader.getBoolean("search.searchlike.similarskn", true);
}
/**
* 超时日志是否打开
*/
public boolean isControllerCostLogOpen() {
return configReader.getBoolean("search.controller.cost.log.open", true);
}
}
... ...
... ... @@ -51,6 +51,8 @@ search.persional.recommend.open=true
#searchlike
search.searchlike.similarskn=true
#log
search.controller.cost.log.open=true
search.persional.rateLimit.brand.productList=200:2
search.persional.rateLimit.brand.aggregations=100:2
... ...