commit
dd14fd0175
|
@ -45,4 +45,10 @@ public class RootController {
|
|||
public String getMetric() {
|
||||
return metricService.getFullMetric();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/status-metric", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String getStatusMetric() {
|
||||
return metricService.getStatusMetric();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.stereotype.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>();
|
||||
|
||||
public MetricService() {
|
||||
super();
|
||||
|
@ -27,9 +28,20 @@ public class MetricService {
|
|||
}
|
||||
statusMap.put(status, count);
|
||||
metricMap.put(request, statusMap);
|
||||
|
||||
final Integer statusCount = statusMetric.get(status);
|
||||
if (statusCount == null) {
|
||||
statusMetric.put(status, 1);
|
||||
} else {
|
||||
statusMetric.put(status, statusCount + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFullMetric() {
|
||||
return metricMap.entrySet().toString();
|
||||
}
|
||||
|
||||
public String getStatusMetric() {
|
||||
return statusMetric.entrySet().toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue