diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index 09ef82beb..f4963448a 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -65,6 +65,7 @@ public class UpdateRecommendations extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateRecommendations.class); + private static int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { @@ -75,7 +76,8 @@ public void init(ServletConfig config) throws ServletException { * Generates recommendations * * @param request an {@link HttpServletRequest} object that - * contains the request the client has made + * contains + * the request the client has made * of the servlet * @param response an {@link HttpServletResponse} object that * contains the response the servlet sends @@ -85,6 +87,8 @@ public void init(ServletConfig config) throws ServletException { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + int calCount = ++requestCount; + LOGGER.debug("UpdateRecommendations API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry()); try { @@ -148,7 +152,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } } - + LOGGER.debug("UpdateRecommendations API request count: {} experiment_name : {} and interval_start_time : {} and interval_end_time : {} ", calCount, experiment_name, intervalStartTimeStr, intervalEndTimeStr); LOGGER.debug("experiment_name : {} and interval_start_time : {} and interval_end_time : {} ", experiment_name, intervalStartTimeStr, intervalEndTimeStr); List experimentResultDataList = new ArrayList<>(); @@ -163,10 +167,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) if (null != kruizeObject) experimentResultDataList = new ExperimentDBService().getExperimentResultData(experiment_name, kruizeObject, interval_start_time, interval_end_time); // Todo this object is not required else { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_EXPERIMENT_NAME, experiment_name)); return; } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return; } @@ -177,12 +183,15 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) new ExperimentInitiator().generateAndAddRecommendations(kruizeObject, experimentResultDataList, interval_start_time, interval_end_time); // TODO: experimentResultDataList not required ValidationOutputData validationOutputData = new ExperimentDBService().addRecommendationToDB(mainKruizeExperimentMAP, experimentResultDataList); if (validationOutputData.isSuccess()) { + LOGGER.debug("UpdateRecommendations API request count: {} success", calCount); sendSuccessResponse(response, kruizeObject, interval_end_time); statusValue = "success"; } else { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, validationOutputData.getMessage()); } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); e.printStackTrace(); LOGGER.error("Failed to create recommendation for experiment: {} and interval_start_time: {} and interval_end_time: {}", experiment_name, @@ -193,14 +202,17 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } else { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_INTERVAL_END_TIME, intervalEndTimeStr)); return; } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + LOGGER.debug("UpdateRecommendations API request count: {} completed", calCount); if (null != timerBUpdateRecommendations) { MetricsConfig.timerUpdateRecomendations = MetricsConfig.timerBUpdateRecommendations.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerBUpdateRecommendations.stop(MetricsConfig.timerUpdateRecomendations); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index 54b34ec05..c923e924e 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -56,6 +56,7 @@ public class UpdateResults extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateResults.class); public static ConcurrentHashMap performanceProfilesMap = new ConcurrentHashMap<>(); + private static int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { @@ -64,12 +65,16 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + int calCount = ++requestCount; + LOGGER.debug("updateResults API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry()); try { String inputData = request.getReader().lines().collect(Collectors.joining()); + LOGGER.debug("updateResults API request payload for requestID {} is {}", calCount, inputData); List experimentResultDataList = new ArrayList<>(); List updateResultsAPIObjects = Arrays.asList(new Gson().fromJson(inputData, UpdateResultsAPIObject[].class)); + LOGGER.debug("updateResults API request payload for requestID {} bulk count is {}", calCount, updateResultsAPIObjects.size()); // check for bulk entries and respond accordingly if (updateResultsAPIObjects.size() > KruizeDeploymentInfo.bulk_update_results_limit) { LOGGER.error(AnalyzerErrorConstants.AutotuneObjectErrors.UNSUPPORTED_EXPERIMENT_RESULTS); @@ -97,16 +102,20 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) ); request.setAttribute("data", jsonObjectList); String errorMessage = String.format("Out of a total of %s records, %s failed to save", updateResultsAPIObjects.size(), failureAPIObjs.size()); + LOGGER.debug("updateResults API request payload for requestID {} failed", calCount); sendErrorResponse(request, response, null, HttpServletResponse.SC_BAD_REQUEST, errorMessage); } else { + LOGGER.debug("updateResults API request payload for requestID {} success", calCount); sendSuccessResponse(response, AnalyzerConstants.ServiceConstants.RESULT_SAVED); statusValue = "success"; } } catch (Exception e) { + LOGGER.debug("updateResults API request payload for requestID {} failed", calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(request, response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + LOGGER.debug("updateResults API request payload for requestID {} completed", calCount); if (null != timerUpdateResults) { MetricsConfig.timerUpdateResults = MetricsConfig.timerBUpdateResults.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerUpdateResults.stop(MetricsConfig.timerUpdateResults);