Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.17] Error visibility: Modifying error logs and logging more details about errors received from remote service #3359

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public void onHeaders(SdkHttpResponse response) {
log.debug("received response headers: " + sdkResponse.headers());
this.statusCode = sdkResponse.statusCode();
if (statusCode < HttpStatus.SC_OK || statusCode > HttpStatus.SC_MULTIPLE_CHOICES) {
log.error("Received error from remote service with status code {}, response headers: {}", statusCode, sdkResponse.headers());
handleThrottlingInHeader(sdkResponse);
// add more handling here for other exceptions in headers
}
Expand All @@ -101,7 +102,7 @@ public void onStream(Publisher<ByteBuffer> stream) {

@Override
public void onError(Throwable error) {
log.error(error.getMessage(), error);
log.error("Received error from remote service: {}", error.getMessage(), error);
RestStatus status = (statusCode == null) ? RestStatus.INTERNAL_SERVER_ERROR : RestStatus.fromCode(statusCode);
String errorMessage = "Error communicating with remote model: " + error.getMessage();
actionListener.onFailure(new OpenSearchStatusException(errorMessage, status));
Expand Down Expand Up @@ -173,6 +174,7 @@ private void response() {
String body = responseBody.toString();

if (exceptionHolder.get() != null) {
log.error("Remote server returned exception with status code: {} and body: {}", statusCode, body);
actionListener.onFailure(exceptionHolder.get());
return;
}
Expand All @@ -184,7 +186,7 @@ private void response() {
}

if (statusCode < HttpStatus.SC_OK || statusCode > HttpStatus.SC_MULTIPLE_CHOICES) {
log.error("Remote server returned error code: {}", statusCode);
log.error("Remote service returned error code: {} with body: {}", statusCode, body);
actionListener.onFailure(new OpenSearchStatusException(REMOTE_SERVICE_ERROR + body, RestStatus.fromCode(statusCode)));
return;
}
Expand Down
Loading