Skip to content

Commit 523cae1

Browse files
committed
Words are good
1 parent 378595d commit 523cae1

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

server/src/main/java/org/elasticsearch/rest/RestResponse.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public RestResponse(RestChannel channel, RestStatus status, Exception e) throws
127127
ToXContent.Params params = channel.request();
128128
if (e != null) {
129129
Level level = status.getStatus() < 500 || ExceptionsHelper.isNodeOrShardUnavailableTypeException(e) ? Level.DEBUG : Level.WARN;
130-
suppressedError(level, channel.request().rawPath(), channel.request().params(), status, e);
130+
logSuppressedError(level, channel.request().rawPath(), channel.request().params(), status, e);
131131
}
132132
// if "error_trace" is turned on in the request, we want to render it in the rest response
133133
// for that the REST_EXCEPTION_SKIP_STACK_TRACE flag that if "true" omits the stack traces is
@@ -245,7 +245,10 @@ public void close() {
245245
Releasables.closeExpectNoException(releasable);
246246
}
247247

248-
public static void suppressedError(Level level, String rawPath, Map<String, String> params, RestStatus status, Exception e) {
248+
/**
249+
* Log failures to the {@code rest.suppressed} logger.
250+
*/
251+
public static void logSuppressedError(Level level, String rawPath, Map<String, String> params, RestStatus status, Exception e) {
249252
if (SUPPRESSED_ERROR_LOGGER.isEnabled(level)) {
250253
SUPPRESSED_ERROR_LOGGER.log(
251254
level,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlResponseListener.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private EsqlResponseListener(RestChannel channel, RestRequest restRequest, Strin
123123

124124
@Override
125125
protected void processResponse(EsqlQueryResponse esqlQueryResponse) throws IOException {
126-
logPartialResponseErrors(channel.request().rawPath(), channel.request().params(), esqlQueryResponse.getExecutionInfo());
126+
logPartialFailures(channel.request().rawPath(), channel.request().params(), esqlQueryResponse.getExecutionInfo());
127127
channel.sendResponse(buildResponse(esqlQueryResponse));
128128
}
129129

@@ -233,10 +233,14 @@ private void checkDelimiter() {
233233
}
234234
}
235235

236-
static void logPartialResponseErrors(String rawPath, Map<String, String> params, EsqlExecutionInfo exeuctionInfo) {
236+
/**
237+
* Log all partial request failures to the {@code rest.suppressed} logger
238+
* so an operator can categorize them after the fact.
239+
*/
240+
static void logPartialFailures(String rawPath, Map<String, String> params, EsqlExecutionInfo exeuctionInfo) {
237241
for (EsqlExecutionInfo.Cluster cluster : exeuctionInfo.getClusters().values()) {
238242
for (ShardSearchFailure failure : cluster.getFailures()) {
239-
RestResponse.suppressedError(org.apache.logging.log4j.Level.WARN, rawPath, params, RestStatus.OK, failure);
243+
RestResponse.logSuppressedError(org.apache.logging.log4j.Level.WARN, rawPath, params, RestStatus.OK, failure);
240244
}
241245
}
242246
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/action/EsqlResponseListenerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void testLogPartialResponseErrors() {
7070
new TimeValue(4444L)
7171
)
7272
);
73-
EsqlResponseListener.logPartialResponseErrors("/_query", Map.of(), executionInfo);
73+
EsqlResponseListener.logPartialFailures("/_query", Map.of(), executionInfo);
7474

7575
LogEvent logEvent = appender.events.get(0);
7676
assertThat(logEvent.getLevel(), equalTo(Level.WARN));

0 commit comments

Comments
 (0)