HTTPRequestWithDecodedQueryParams requestWithParams = (HTTPRequestWithDecodedQueryParams) request;
final Timer.Context httpBatchMetricsFetchTimerContext = httpBatchMetricsFetchTimer.time();
try {
RollupsQueryParams params = PlotRequestParser.parseParams(requestWithParams.getQueryParams());
BatchMetricsQuery query = new BatchMetricsQuery(locators, params.getRange(), params.getGranularity());
Map<Locator, MetricData> results = new BatchMetricsQueryHandler(executor, AstyanaxReader.getInstance())
.execute(query, queryTimeout);
JSONObject metrics = serializer.transformRollupData(results, params.getStats());
final JsonElement element = parser.parse(metrics.toString());
final String jsonStringRep = gson.toJson(element);
sendResponse(ctx, request, jsonStringRep, HttpResponseStatus.OK);
} catch (InvalidRequestException e) {
sendResponse(ctx, request, e.getMessage(), HttpResponseStatus.BAD_REQUEST);