Skip to content

Commit

Permalink
Add additional log to track unsatisfied requests (#1372)
Browse files Browse the repository at this point in the history
Print out more info of unsatisfied requests for investigation.
  • Loading branch information
jsjtzyy authored Feb 7, 2020
1 parent af2c067 commit edfa224
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ public enum ResponseStatus {
this.statusCode = statusCode;
}

/**
* @return status code of this {@link ResponseStatus}
*/
public int getStatusCode() {
return statusCode;
}

/**
* @return {@code true} if status code is 2xx which means success. {@code false} otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,37 @@ private void evaluatePerformanceAndUpdateMetrics() {
.checkThresholds(requestPerfToCheck))) {
// this means either response is 5xx or request missed one of thresholds, the request should be unsatisfied
restRequestMetricsTracker.markUnsatisfied();
logUnsatisfiedRequest(requestPerfToCheck);
}
restRequestMetricsTracker.recordMetrics();
}

/**
* Log unsatisfied request (print out request/response info and performance indices)
* @param requestPerfToCheck the performance indices associated with this request.
*/
private void logUnsatisfiedRequest(Map<PerformanceIndex, Long> requestPerfToCheck) {
StringBuilder sb = new StringBuilder();
sb.append("Unsatisfied request: uri=").append(request.getUri()).append("; method=").append(request.getRestMethod());
if (request.getRestMethod() == RestMethod.POST) {
sb.append("; location=").append((String) getHeader(RestUtils.Headers.LOCATION));
}
sb.append("; status=").append(responseStatus.getStatusCode());
Object blobSize = getHeader(RestUtils.Headers.BLOB_SIZE);
if (blobSize != null) {
sb.append("; blob size=").append((String) blobSize);
}
for (Map.Entry<PerformanceIndex, Long> entry : requestPerfToCheck.entrySet()) {
sb.append("; ").append(entry.getKey().toString()).append("=").append(entry.getValue());
if (entry.getKey() == PerformanceIndex.AverageBandwidth) {
sb.append("bytes/sec");
} else {
sb.append("ms");
}
}
logger.warn(sb.toString());
}

/**
* Writes response metadata to the channel if not already written previously and channel is active.
* @param responseMetadata the {@link HttpResponse} that needs to be written.
Expand Down

0 comments on commit edfa224

Please sign in to comment.