Source:
private void evaluatePerformanceAndUpdateMetrics() { RestRequestMetricsTracker restRequestMetricsTracker = request.getMetricsTracker(); long roundTripTimeInMs = restRequestMetricsTracker.getRoundTripTimeInMs(); long timeToFirstBytesInMs = restRequestMetricsTracker.getTimeToFirstByteInMs(); long totalOutboundBytes = totalBytesReceived.get(); long totalInboundBytes = request.getBytesReceived(); RestMethod method = request.getRestMethod(); Map<PerformanceIndex, Long> requestPerfToCheck = new HashMap<>(); responseStatus = errorResponseStatus == null ? responseStatus : errorResponseStatus; boolean shouldSkipCheck = false; switch (method) { case GET: if (successResponseSet.contains(responseStatus)) { requestPerfToCheck.put(PerformanceIndex.TimeToFirstByte, timeToFirstBytesInMs); requestPerfToCheck.put(PerformanceIndex.AverageBandwidth, totalOutboundBytes * 1000L / roundTripTimeInMs); } else if (nonSuccessResponseSet.contains(responseStatus)) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; case POST: if (successResponseSet.contains(responseStatus)) { requestPerfToCheck.put(PerformanceIndex.AverageBandwidth, totalInboundBytes * 1000L / roundTripTimeInMs); } else if (nonSuccessResponseSet.contains(responseStatus)) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; case PUT: case HEAD: case DELETE: if (successResponseSet.contains(responseStatus) || nonSuccessResponseSet.contains(responseStatus)) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; default: shouldSkipCheck = true; logger.warn("Temporarily no evaluation criteria for " + method + " request. Mark as satisfied directly"); } EnumMap<RestMethod, Threshold> thresholdsByMethod = successResponseSet.contains(responseStatus) ? perfConfig.successRequestThresholds : perfConfig.nonSuccessRequestThresholds; if (!shouldSkipCheck && (requestPerfToCheck.isEmpty() || !thresholdsByMethod.get(method) .checkThresholds(requestPerfToCheck))) { restRequestMetricsTracker.markUnsatisfied(); } restRequestMetricsTracker.recordMetrics(); }

Target:
private void evaluatePerformanceAndUpdateMetrics() { RestRequestMetricsTracker restRequestMetricsTracker = request.getMetricsTracker(); long roundTripTimeInMs = restRequestMetricsTracker.getRoundTripTimeInMs(); long timeToFirstBytesInMs = restRequestMetricsTracker.getTimeToFirstByteInMs(); long totalOutboundBytes = totalBytesReceived.get(); long totalInboundBytes = request.getBytesReceived(); RestMethod method = request.getRestMethod(); Map<PerformanceIndex, Long> requestPerfToCheck = new HashMap<>(); if (errorResponseStatus != null) { responseStatus = errorResponseStatus; } boolean shouldSkipCheck = false; switch (method) { case GET: if (responseStatus.isSuccess()) { requestPerfToCheck.put(PerformanceIndex.TimeToFirstByte, timeToFirstBytesInMs); requestPerfToCheck.put(PerformanceIndex.AverageBandwidth, roundTripTimeInMs == 0L ? Long.MAX_VALUE : totalOutboundBytes * 1000L / roundTripTimeInMs); } else if (responseStatus.isClientError() || responseStatus.isRedirection()) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; case POST: if (responseStatus.isSuccess()) { requestPerfToCheck.put(PerformanceIndex.AverageBandwidth, roundTripTimeInMs == 0L ? Long.MAX_VALUE : totalInboundBytes * 1000L / roundTripTimeInMs); } else if (responseStatus.isClientError() || responseStatus.isRedirection()) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; case PUT: case HEAD: case DELETE: if (!responseStatus.isServerError()) { requestPerfToCheck.put(PerformanceIndex.RoundTripTime, roundTripTimeInMs); } break; default: shouldSkipCheck = true; logger.debug("Temporarily no evaluation criteria for request. Mark as satisfied directly", method); } EnumMap<RestMethod, Thresholds> thresholdsByMethod = responseStatus.isSuccess() ? perfConfig.successRequestThresholds : perfConfig.nonSuccessRequestThresholds; if (!shouldSkipCheck && (responseStatus.isServerError() || !thresholdsByMethod.get(method) .checkThresholds(requestPerfToCheck))) { restRequestMetricsTracker.markUnsatisfied(); } restRequestMetricsTracker.recordMetrics(); }