Encode and then decode GET /metrics response to fix serialization issue with Vertx's JsonObject

This commit is contained in:
Colin McDonald 2016-07-10 15:43:29 -04:00
parent 529bf25daf
commit 45a706e0d7
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import io.vertx.core.json.JsonObject;
import io.vertx.ext.dropwizard.MetricsService;
import io.vertx.ext.web.RoutingContext;
import net.frozenorb.apiv3.APIv3;
import org.bson.Document;
public final class GETMetrics implements Handler<RoutingContext> {
@ -12,7 +13,8 @@ public final class GETMetrics implements Handler<RoutingContext> {
MetricsService metricsService = MetricsService.create(APIv3.getVertxInstance());
JsonObject metrics = metricsService.getMetricsSnapshot(APIv3.getVertxInstance());
APIv3.respondJson(ctx, 200, metrics);
// We encode and then parse because JsonObject and Gson don't play nicely with each other
APIv3.respondJson(ctx, 200, Document.parse(metrics.encode()));
}
}