Skip to content

Commit

Permalink
ESQL: Merge more code into esql-proper (#110432)
Browse files Browse the repository at this point in the history
This removes the `Graphviz` class which we don't currently use and
merges the `LoggingUtils` class into it's single caller,
`EsqlResponseListener`.
  • Loading branch information
nik9000 authored Jul 3, 2024
1 parent f30a6d9 commit 1dc7eaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 339 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

package org.elasticsearch.xpack.esql.action;

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.logging.Level;
import org.elasticsearch.logging.LogManager;
import org.elasticsearch.logging.Logger;
import org.elasticsearch.rest.ChunkedRestResponseBodyPart;
Expand All @@ -29,7 +31,6 @@
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.esql.core.util.LoggingUtils.logOnFailure;
import static org.elasticsearch.xpack.esql.formatter.TextFormat.CSV;
import static org.elasticsearch.xpack.esql.formatter.TextFormat.URL_PARAM_DELIMITER;

Expand Down Expand Up @@ -168,7 +169,7 @@ private RestResponse buildResponse(EsqlQueryResponse esqlResponse) throws IOExce
*/
public ActionListener<EsqlQueryResponse> wrapWithLogging() {
ActionListener<EsqlQueryResponse> listener = ActionListener.wrap(this::onResponse, ex -> {
logOnFailure(LOGGER, ex);
logOnFailure(ex);
onFailure(ex);
});
if (LOGGER.isDebugEnabled() == false) {
Expand All @@ -190,4 +191,8 @@ public ActionListener<EsqlQueryResponse> wrapWithLogging() {
});
}

static void logOnFailure(Throwable throwable) {
RestStatus status = ExceptionsHelper.status(throwable);
LOGGER.log(status.getStatus() >= 500 ? Level.WARN : Level.DEBUG, () -> "Request failed with status [" + status + "]: ", throwable);
}
}

0 comments on commit 1dc7eaf

Please sign in to comment.