Add spring boot metrics
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user