use of com.netflix.hystrix.HystrixRequestLog in project Hystrix by Netflix.
the class HystrixRequestLogViaLoggerServletFilter method doFilter.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
StringBuilder requestURL = new StringBuilder();
try {
// get the requested URL for our logging so it can be associated to a particular request
String uri = ((HttpServletRequest) request).getRequestURI();
String queryString = ((HttpServletRequest) request).getQueryString();
String method = ((HttpServletRequest) request).getMethod();
requestURL.append(method).append(" ").append(uri);
if (queryString != null) {
requestURL.append("?").append(queryString);
}
chain.doFilter(request, response);
} finally {
try {
if (HystrixRequestContext.isCurrentThreadInitialized()) {
HystrixRequestLog log = HystrixRequestLog.getCurrentRequest();
logger.info("Hystrix Executions [{}] => {}", requestURL.toString(), log.getExecutedCommandsAsString());
}
} catch (Exception e) {
logger.warn("Unable to append HystrixRequestLog", e);
}
}
}
Aggregations