Skip to content

Commit

Permalink
Simplify logging in InternalClusterInfoService (elastic#82673)
Browse files Browse the repository at this point in the history
In [1] we decided that the logging introduced in elastic#66993 was a bit sneaky
and not really the pattern we want to follow. We want to hide stack
traces for boring network errors but in practice that means
`NodeDisconnectedException` and `ReceiveTimeoutTransportException` whose
stack traces are already suppressed (see elastic#75671) so really it's fine to
log the full exception at `WARN` level in all cases. This commit does
that.

[1] https://github.com/elastic/elasticsearch/pull/75544/files#r675113968
  • Loading branch information
DaveCTurner authored Jan 31, 2022
1 parent 0146808 commit 9c992d7
Showing 1 changed file with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,10 @@ public void onResponse(NodesStatsResponse nodesStatsResponse) {
logger.trace("received node stats response");

for (final FailedNodeException failure : nodesStatsResponse.failures()) {
final Throwable cause = failure.getCause();
if (logger.isDebugEnabled()) {
logger.warn(new ParameterizedMessage("failed to retrieve stats for node [{}]", failure.nodeId()), cause);
} else {
logger.warn("failed to retrieve stats for node [{}]: {}", failure.nodeId(), cause.getMessage());
}
logger.warn(
new ParameterizedMessage("failed to retrieve stats for node [{}]", failure.nodeId()),
failure.getCause()
);
}

ImmutableOpenMap.Builder<String, DiskUsage> leastAvailableUsagesBuilder = ImmutableOpenMap.builder();
Expand Down Expand Up @@ -223,21 +221,13 @@ public void onResponse(IndicesStatsResponse indicesStatsResponse) {
for (final DefaultShardOperationFailedException shardFailure : indicesStatsResponse.getShardFailures()) {
if (shardFailure.getCause()instanceof final FailedNodeException failedNodeException) {
if (failedNodeIds.add(failedNodeException.nodeId())) {
if (logger.isDebugEnabled()) {
logger.warn(
new ParameterizedMessage(
"failed to retrieve shard stats from node [{}]",
failedNodeException.nodeId()
),
failedNodeException
);
} else {
logger.warn(
"failed to retrieve shard stats from node [{}]: {}",
failedNodeException.nodeId(),
failedNodeException.getCause().getMessage()
);
}
logger.warn(
new ParameterizedMessage(
"failed to retrieve shard stats from node [{}]",
failedNodeException.nodeId()
),
failedNodeException.getCause()
);
}
logger.trace(
new ParameterizedMessage(
Expand Down

0 comments on commit 9c992d7

Please sign in to comment.