[7.x][ML] Include cause in logging during test inference (#60749) (#60805)

When an exception is thrown during test inference we are
not including the cause message in our logging. This commit
addresses this issue.

Backport of #60749
This commit is contained in:
Dimitris Athanasiou 2020-08-06 11:45:59 +03:00 committed by GitHub
parent f8a63bbdb5
commit cedbe6968b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.dataframe.inference;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.index.IndexRequest;
@ -87,7 +88,9 @@ public class InferenceRunner {
inferTestDocs(localModel, testDocsIterator);
}
} catch (Exception e) {
throw ExceptionsHelper.serverError("[{}] failed running inference on model [{}]", e, config.getId(), modelId);
LOGGER.error(new ParameterizedMessage("[{}] Error during inference against model [{}]", config.getId(), modelId), e);
throw ExceptionsHelper.serverError("[{}] failed running inference on model [{}]; cause was [{}]", e, config.getId(), modelId,
e.getMessage());
}
}