Add spring boot metrics

This commit is contained in:
DOHA
2015-03-26 20:25:44 +02:00
parent 90b5676dca
commit d696c4d236
8 changed files with 197 additions and 5 deletions
@@ -9,13 +9,15 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class MetricFilter implements Filter {
private MetricService metricService;
@Override
public void init(final FilterConfig config) throws ServletException {
metricService = new MetricService();
metricService = (MetricService) WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext()).getBean("metricService");
}
@Override
@@ -11,13 +11,16 @@ import org.springframework.stereotype.Service;
@Service
public class MetricService {
private static HashMap<String, HashMap<Integer, Integer>> metricMap = new HashMap<String, HashMap<Integer, Integer>>();
private static HashMap<Integer, Integer> statusMetric = new HashMap<Integer, Integer>();
private static HashMap<String, HashMap<Integer, Integer>> timeMap = new HashMap<String, HashMap<Integer, Integer>>();
private HashMap<String, HashMap<Integer, Integer>> metricMap;
private HashMap<Integer, Integer> statusMetric;
private HashMap<String, HashMap<Integer, Integer>> timeMap;
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
public MetricService() {
super();
metricMap = new HashMap<String, HashMap<Integer, Integer>>();
statusMetric = new HashMap<Integer, Integer>();
timeMap = new HashMap<String, HashMap<Integer, Integer>>();
}
public void increaseCount(final String request, final int status) {