Merge pull request #168 from Doha2012/master

modify metric
This commit is contained in:
Eugen 2015-03-21 23:34:07 +02:00
commit dd14fd0175
2 changed files with 18 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}