Skip to content

Commit

Permalink
reduce log level of occurring "precondition" DittoRuntimeExceptions t…
Browse files Browse the repository at this point in the history
…o "DEBUG"
  • Loading branch information
thjaeckle committed May 14, 2024
1 parent 4889b0a commit 4da8acc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.eclipse.ditto.base.model.acks.AcknowledgementLabel;
import org.eclipse.ditto.base.model.acks.AcknowledgementRequest;
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
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.DittoRuntimeException;
Expand Down Expand Up @@ -553,14 +554,17 @@ private Object handleErrorResponse(final DittoRuntimeException exception, final

final ThreadSafeDittoLoggingAdapter l = logger.withCorrelationId(exception);

if (l.isInfoEnabled()) {
l.info("Got DittoRuntimeException '{}' when ExternalMessage was processed: {} - {}",
exception.getErrorCode(), exception.getMessage(), exception.getDescription().orElse(""));
if (exception.getHttpStatus().equals(HttpStatus.PRECONDITION_FAILED)) {
l.debug("Precondition failed when ExternalMessage was processed: <{}: {}>",
exception.getClass().getSimpleName(), exception.getMessage());
} else {
l.info("Got DittoRuntimeException when ExternalMessage was processed: <{}: {}> - {}",
exception.getClass().getSimpleName(), exception.getMessage(), exception.getDescription().orElse(""));
}
if (l.isDebugEnabled()) {
final String stackTrace = stackTraceAsString(exception);
l.debug("Got DittoRuntimeException '{}' when ExternalMessage was processed: {} - {}. StackTrace: {}",
exception.getErrorCode(), exception.getMessage(), exception.getDescription().orElse(""),
l.debug("Got DittoRuntimeException when ExternalMessage was processed: <{}: {}> - {}. StackTrace: {}",
exception.getClass().getSimpleName(), exception.getMessage(), exception.getDescription().orElse(""),
stackTrace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@

import javax.annotation.Nullable;

import org.apache.pekko.actor.AbstractExtensionId;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.ExtendedActorSystem;
import org.apache.pekko.actor.Extension;
import org.apache.pekko.cluster.pubsub.DistributedPubSubMessage;
import org.apache.pekko.pattern.AskTimeoutException;
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
import org.eclipse.ditto.base.model.common.HttpStatus;
import org.eclipse.ditto.base.model.exceptions.AskException;
import org.eclipse.ditto.base.model.exceptions.DittoInternalErrorException;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
Expand All @@ -28,21 +36,13 @@
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.base.model.signals.commands.CommandResponse;
import org.eclipse.ditto.edge.service.EdgeServiceTimeoutException;
import org.eclipse.ditto.internal.utils.pekko.PekkoClassLoader;
import org.eclipse.ditto.internal.utils.pekko.logging.DittoLoggerFactory;
import org.eclipse.ditto.internal.utils.pekko.logging.ThreadSafeDittoLogger;
import org.eclipse.ditto.internal.utils.cacheloaders.AskWithRetry;
import org.eclipse.ditto.internal.utils.cacheloaders.config.AskWithRetryConfig;
import org.eclipse.ditto.internal.utils.cacheloaders.config.DefaultAskWithRetryConfig;
import org.eclipse.ditto.internal.utils.config.DefaultScopedConfig;

import org.apache.pekko.actor.AbstractExtensionId;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.ExtendedActorSystem;
import org.apache.pekko.actor.Extension;
import org.apache.pekko.cluster.pubsub.DistributedPubSubMessage;
import org.apache.pekko.pattern.AskTimeoutException;
import org.eclipse.ditto.internal.utils.pekko.PekkoClassLoader;
import org.eclipse.ditto.internal.utils.pekko.logging.DittoLoggerFactory;
import org.eclipse.ditto.internal.utils.pekko.logging.ThreadSafeDittoLogger;

/**
* Forwards commands from the edges to a specified ActorRef, waiting for a response if the command demands one.
Expand Down Expand Up @@ -208,7 +208,13 @@ private DittoRuntimeException reportError(final Command<?> command,
: throwable;
final var dre = DittoRuntimeException.asDittoRuntimeException(
error, t -> reportUnexpectedError(command, t));
LOGGER.withCorrelationId(command).info("{}: {}", dre.getClass().getSimpleName(), dre.getMessage());
if (dre.getHttpStatus().equals(HttpStatus.PRECONDITION_FAILED)) {
LOGGER.withCorrelationId(command)
.debug("Precondition failed: <{}: {}>", dre.getClass().getSimpleName(), dre.getMessage());
} else {
LOGGER.withCorrelationId(command)
.info("{}: {}", dre.getClass().getSimpleName(), dre.getMessage());
}
return dre;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.pekko.stream.javadsl.StreamRefs;
import org.bson.BsonDocument;
import org.eclipse.ditto.base.api.commands.sudo.SudoCommand;
import org.eclipse.ditto.base.model.common.HttpStatus;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.exceptions.DittoInternalErrorException;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
Expand Down Expand Up @@ -833,14 +834,22 @@ private void handleSignalEnforcementResponse(@Nullable final Object response,

if (null != throwable) {
final DittoRuntimeException dre = getEnforcementExceptionAsRuntimeException(throwable, signal);
log.withCorrelationId(dre)
.info("Received DittoRuntimeException during enforcement or " +
"forwarding to target actor, telling sender: {}", dre);
if (dre.getHttpStatus().equals(HttpStatus.PRECONDITION_FAILED)) {
log.withCorrelationId(dre)
.debug("Precondition during enforcement or " +
"forwarding to target actor, telling sender: {}", dre);
} else {
log.withCorrelationId(dre)
.info("Received DittoRuntimeException during enforcement or " +
"forwarding to target actor, telling sender: {}", dre);
}
sender.tell(dre, getSelf());
} else if (response instanceof Status.Success success) {
log.withCorrelationId(signal).debug("Ignoring Status.Success message as expected 'to be ignored' outcome: <{}>", success);
log.withCorrelationId(signal)
.debug("Ignoring Status.Success message as expected 'to be ignored' outcome: <{}>", success);
} else if (null != response) {
log.withCorrelationId(signal).debug("Sending response: <{}> back to sender: <{}>", response, sender.path());
log.withCorrelationId(signal)
.debug("Sending response: <{}> back to sender: <{}>", response, sender.path());
sender.tell(response, getSelf());
} else {
log.withCorrelationId(signal)
Expand Down

0 comments on commit 4da8acc

Please sign in to comment.