Skip to content

Commit

Permalink
added new MDC key "ditto-log-tag" used in Connection live status logs…
Browse files Browse the repository at this point in the history
… + switched misconfiguration to "warning" level

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Jul 28, 2021
1 parent 794454e commit 7127dad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import org.eclipse.ditto.connectivity.service.messaging.validation.DittoConnectivityCommandValidator;
import org.eclipse.ditto.connectivity.service.util.ConnectivityMdcEntryKey;
import org.eclipse.ditto.internal.utils.akka.PingCommand;
import org.eclipse.ditto.internal.utils.akka.logging.CommonMdcEntryKey;
import org.eclipse.ditto.internal.utils.akka.logging.DittoDiagnosticLoggingAdapter;
import org.eclipse.ditto.internal.utils.akka.logging.DittoLoggerFactory;
import org.eclipse.ditto.internal.utils.cluster.DistPubSubAccess;
Expand Down Expand Up @@ -465,13 +466,15 @@ private void askSelfForRetrieveConnectionStatus(@Nullable final String correlati
.whenComplete((response, throwable) -> {
if (response instanceof RetrieveConnectionStatusResponse) {
final RetrieveConnectionStatusResponse rcsResp = (RetrieveConnectionStatusResponse) response;
final DittoDiagnosticLoggingAdapter l = log.withCorrelationId(rcsResp);
final DittoDiagnosticLoggingAdapter l = log
.withMdcEntry(CommonMdcEntryKey.DITTO_LOG_TAG, "connection-live-status")
.withCorrelationId(rcsResp);
final ConnectivityStatus liveStatus = rcsResp.getLiveStatus();
final String template = "Calculated <{}> live ConnectionStatus: <{}>";
if (liveStatus == ConnectivityStatus.FAILED) {
l.error(template, liveStatus, rcsResp);
} else if (liveStatus == ConnectivityStatus.MISCONFIGURED) {
l.info(template, liveStatus, rcsResp);
l.warning(template, liveStatus, rcsResp);
} else {
l.info(template, liveStatus, rcsResp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
*/
public enum CommonMdcEntryKey implements CharSequence {

CORRELATION_ID("x-correlation-id");
CORRELATION_ID("x-correlation-id"),
DITTO_LOG_TAG("ditto-log-tag");

private final String key;

private CommonMdcEntryKey(final String key) {
CommonMdcEntryKey(final String key) {
this.key = key;
}

Expand Down

0 comments on commit 7127dad

Please sign in to comment.