Source:
<code>private void processResponses() { Iterator<Map.Entry<RestRequest, AsyncResponseInfo>> responseIterator = responses.entrySet().iterator(); while (responseIterator.hasNext()) { Map.Entry<RestRequest, AsyncResponseInfo> responseInfo = responseIterator.next(); long processingStartTime = System.currentTimeMillis(); long responseProcessingTime = 0; RestRequest restRequest = responseInfo.getKey(); try { AsyncResponseInfo asyncResponseInfo = responseInfo.getValue(); ReadableStreamChannel response = asyncResponseInfo.getResponse(); RestResponseChannel restResponseChannel = asyncResponseInfo.getRestResponseChannel(); int bytesWritten = 0; Exception exception = null; try { <START> long processingDelay = asyncResponseInfo.getProcessingDelay(); <END> restRequest.getMetricsTracker().scalingMetricsTracker.addToResponseProcessingDelay(processingDelay); long responseWriteStartTime = System.currentTimeMillis(); bytesWritten = response.read(restResponseChannel); responseProcessingTime = System.currentTimeMillis() - responseWriteStartTime; logger.trace("{} response bytes were written for request {}", bytesWritten, restRequest.getUri()); } catch (Exception e) { restServerMetrics.responseProcessingError.inc(); exception = e; } if (bytesWritten == -1 || exception != null) { long responseCompleteStartTime = System.currentTimeMillis(); onResponseComplete(restRequest, restResponseChannel, exception, false); responseProcessingTime += (System.currentTimeMillis() - responseCompleteStartTime); releaseResources(response); responseIterator.remove(); queuedResponseCount.decrementAndGet(); restServerMetrics.responseCompletionRate.mark(); logger.trace("Response complete for request {}", restRequest.getUri()); } else { asyncResponseInfo.recordProcessingEndTime(); } } finally { restRequest.getMetricsTracker().scalingMetricsTracker .addToResponseProcessingTime(System.currentTimeMillis() - processingStartTime - responseProcessingTime); } } }</code><technical_language>I getProcessingWaitTime more sense recording total time spent in waiting state. Delay sort of conveys initial wait time (which sense previous approach)</technical_language>

Target:
private void processResponses() { Iterator<Map.Entry<RestRequest, AsyncResponseInfo>> responseIterator = responses.entrySet().iterator(); while (responseIterator.hasNext()) { Map.Entry<RestRequest, AsyncResponseInfo> responseInfo = responseIterator.next(); long processingStartTime = System.currentTimeMillis(); long responseProcessingTime = 0; RestRequest restRequest = responseInfo.getKey(); try { AsyncResponseInfo asyncResponseInfo = responseInfo.getValue(); ReadableStreamChannel response = asyncResponseInfo.getResponse(); RestResponseChannel restResponseChannel = asyncResponseInfo.getRestResponseChannel(); int bytesWritten = 0; Exception exception = null; try { long processingDelay = asyncResponseInfo.getProcessingDelay(); restRequest.getMetricsTracker().scalingMetricsTracker.addToResponseProcessingWaitTime(processingDelay); long responseWriteStartTime = System.currentTimeMillis(); bytesWritten = response.read(restResponseChannel); responseProcessingTime = System.currentTimeMillis() - responseWriteStartTime; logger.trace("{} response bytes were written for request {}", bytesWritten, restRequest.getUri()); } catch (Exception e) { restServerMetrics.responseProcessingError.inc(); exception = e; } if (bytesWritten == -1 || exception != null) { long responseCompleteStartTime = System.currentTimeMillis(); onResponseComplete(restRequest, restResponseChannel, exception, false); responseProcessingTime += (System.currentTimeMillis() - responseCompleteStartTime); releaseResources(response); responseIterator.remove(); queuedResponseCount.decrementAndGet(); restServerMetrics.responseCompletionRate.mark(); logger.trace("Response complete for request {}", restRequest.getUri()); } else { asyncResponseInfo.recordProcessingEndTime(); } } finally { restRequest.getMetricsTracker().scalingMetricsTracker .addToResponseProcessingTime(System.currentTimeMillis() - processingStartTime - responseProcessingTime); } } }