Skip to content

Commit

Permalink
improve AskWithRetry WARN logging
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
  • Loading branch information
thjaeckle committed Jun 21, 2023
1 parent 1e9f8fa commit dd9683c
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -25,6 +25,8 @@
import javax.annotation.Nullable;

import org.eclipse.ditto.base.model.common.HttpStatus;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.entity.id.WithEntityId;
import org.eclipse.ditto.base.model.exceptions.AskException;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeExceptionBuilder;
Expand Down Expand Up @@ -196,9 +198,21 @@ private static <M, A> CompletionStage<AskResult<A>> createAskHandle(final ActorR
ThreadSafeDittoLogger l = LOGGER;
if (null != dittoHeaders) {
l = LOGGER.withCorrelationId(dittoHeaders);
} else if (message instanceof WithDittoHeaders withDittoHeaders) {
l = LOGGER.withCorrelationId(withDittoHeaders.getDittoHeaders());
}
l.warn("Got AskTimeout during ask for message <{}> - retrying.. : <{}>",
message.getClass().getSimpleName(), throwable.getMessage());
final EntityId entityId;
if (message instanceof WithEntityId withEntityId) {
entityId = withEntityId.getEntityId();
} else {
entityId = null;
}
l.warn("Got AskTimeout during ask for message <{}> and entityId <{} / {}> - retrying.. : <{}>",
message.getClass().getSimpleName(),
entityId,
entityId != null ? entityId.getEntityType() : null,
throwable.getMessage()
);
}
// all non-known RuntimeException should be handled by the "Patterns.retry" with a retry:
throw new UnknownAskRuntimeException(throwable);
Expand Down

0 comments on commit dd9683c

Please sign in to comment.