fix map metric
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m57s

This commit is contained in:
Lee 2024-04-14 09:42:39 +01:00
parent e9da32775f
commit 8d45ba8cbd
2 changed files with 19 additions and 1 deletions

@ -44,6 +44,8 @@ public class MetricService {
registerMetric(new TotalRequestsMetric());
registerMetric(new RequestsPerRouteMetric());
// todo: don't bother saving and loading metrics when running tests
// Load the metrics from Redis
loadMetrics();

@ -16,7 +16,23 @@ public class MapMetric <A, B> extends Metric<Map<A, B>> {
public Point toPoint() {
Point point = Point.measurement(getId());
for (Map.Entry<A, B> entry : getValue().entrySet()) {
point.addField(entry.getKey().toString(), entry.getValue().toString());
switch (entry.getValue().getClass().getSimpleName()) {
case "Integer":
point.addField(entry.getKey().toString(), (Integer) entry.getValue());
break;
case "Double":
point.addField(entry.getKey().toString(), (Double) entry.getValue());
break;
case "String":
point.addField(entry.getKey().toString(), (String) entry.getValue());
break;
case "Boolean":
point.addField(entry.getKey().toString(), (Boolean) entry.getValue());
break;
default:
point.addField(entry.getKey().toString(), entry.getValue().toString());
break;
}
}
return point;
}