forName(@Nullable final CharSequence name) {
+ return Stream.of(values())
+ .filter(l -> Objects.equals(l.key, String.valueOf(name)))
+ .findAny();
+ }
+
+ /**
+ * Extracts a list of MdcEntries based on the given {@code headers} map, picking out explicitly headers which should
+ * be added to the MDC.
+ *
+ * This method is called a lot of times in Ditto's codebase and therefore better be fast. This was achieved by not
+ * iterating over all headers, but to accessing the passed {@code HashMap} for picking out only the supported
+ * headers.
+ *
+ *
+ * @param headers the headers to look into for extracting the MDC worthy headers to log.
+ * @return a list of MDC entries to add to the MDC.
+ */
+ public static List extractMdcEntriesFromHeaders(@Nullable final Map headers) {
+
+ if (null == headers || headers.isEmpty()) {
+ return Collections.emptyList();
+ }
+ return Stream.of(CORRELATION_ID, TRACE_PARENT)
+ .flatMap(mdcEntryKey -> extractValue(headers, mdcEntryKey))
+ .toList();
+ }
+
+ private static Stream extractValue(final Map headers,
+ final CommonMdcEntryKey mdcEntryKey) {
+
+ if (mdcEntryKey == TRACE_PARENT) {
+ return Optional.ofNullable(headers.get(mdcEntryKey.key))
+ .filter(traceParent -> traceParent.charAt(2) == '-' && traceParent.length() == 55)
+ .map(traceParent -> Stream.of(
+ // positions defined by https://www.w3.org/TR/trace-context/#traceparent-header-field-values to contain the "trace-id"
+ MdcEntry.of(TRACE_ID, traceParent.substring(3, 35)),
+ MdcEntry.of(SPAN_ID, traceParent.substring(36, 52))
+ )).stream()
+ .flatMap(Function.identity());
+ } else {
+ return Optional.ofNullable(headers.get(mdcEntryKey.key))
+ .map(value -> MdcEntry.of(mdcEntryKey.key, value))
+ .stream();
+ }
+ }
+
}
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapter.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapter.java
index d38376690a..a142456169 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapter.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapter.java
@@ -24,7 +24,6 @@
import org.eclipse.ditto.base.model.headers.WithDittoHeaders;
import org.apache.pekko.event.DiagnosticLoggingAdapter;
-import scala.collection.JavaConverters;
import scala.collection.immutable.Seq;
/**
@@ -73,29 +72,18 @@ public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final Ch
}
@Override
- public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final WithDittoHeaders withDittoHeaders) {
- return withCorrelationId(null != withDittoHeaders ? withDittoHeaders.getDittoHeaders() : null);
- }
-
- @Override
- public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final DittoHeaders dittoHeaders) {
- return withCorrelationId(null != dittoHeaders ? dittoHeaders.getCorrelationId().orElse(null) : null);
- }
-
- @Override
- public DefaultDittoDiagnosticLoggingAdapter setCorrelationId(@Nullable final CharSequence correlationId) {
- return setMdcEntry(CommonMdcEntryKey.CORRELATION_ID, correlationId);
+ public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final Map headers) {
+ return withMdcEntries(CommonMdcEntryKey.extractMdcEntriesFromHeaders(headers));
}
@Override
- public DefaultDittoDiagnosticLoggingAdapter setCorrelationId(final WithDittoHeaders withDittoHeaders) {
- return setCorrelationId(checkNotNull(withDittoHeaders, "withDittoHeaders").getDittoHeaders());
+ public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final WithDittoHeaders withDittoHeaders) {
+ return withCorrelationId(null != withDittoHeaders ? withDittoHeaders.getDittoHeaders() : null);
}
@Override
- public DefaultDittoDiagnosticLoggingAdapter setCorrelationId(final DittoHeaders dittoHeaders) {
- checkNotNull(dittoHeaders, "dittoHeaders");
- return setCorrelationId(dittoHeaders.getCorrelationId().orElse(null));
+ public DefaultDittoDiagnosticLoggingAdapter withCorrelationId(@Nullable final DittoHeaders dittoHeaders) {
+ return withCorrelationId(null != dittoHeaders ? dittoHeaders : Map.of());
}
@Override
@@ -150,30 +138,6 @@ private void removeFromMdcOfAllLoggerStates(final CharSequence key) {
autoDiscardingLoggingAdapter.removeMdcEntry(key);
}
- @Override
- public DefaultDittoDiagnosticLoggingAdapter setMdcEntry(final MdcEntry mdcEntry,
- final Seq furtherMdcEntries) {
-
- currentLogger = loggingAdapter;
- putToMdcOfAllLoggerStates(mdcEntry.getKey(), mdcEntry.getValueOrNull());
- final Collection furtherMdcEntriesCollection = JavaConverters.asJavaCollection(furtherMdcEntries);
- furtherMdcEntriesCollection.forEach(furtherMdcEntry -> putToMdcOfAllLoggerStates(furtherMdcEntry.getKey(),
- furtherMdcEntry.getValueOrNull()));
- return this;
- }
-
- @Override
- public DefaultDittoDiagnosticLoggingAdapter setMdcEntry(final MdcEntry mdcEntry,
- final MdcEntry... furtherMdcEntries) {
-
- currentLogger = loggingAdapter;
- putToMdcOfAllLoggerStates(mdcEntry.getKey(), mdcEntry.getValueOrNull());
- for (final MdcEntry furtherMdcEntry : furtherMdcEntries) {
- putToMdcOfAllLoggerStates(furtherMdcEntry.getKey(), furtherMdcEntry.getValueOrNull());
- }
- return this;
- }
-
@Override
public DefaultDittoDiagnosticLoggingAdapter putMdcEntry(final CharSequence key,
@Nullable final CharSequence value) {
@@ -226,6 +190,15 @@ public DittoDiagnosticLoggingAdapter withMdcEntry(final MdcEntry mdcEntry, final
return this;
}
+ @Override
+ public DefaultDittoDiagnosticLoggingAdapter withMdcEntries(final Collection mdcEntries) {
+ checkNotNull(mdcEntries, "mdcEntries");
+
+ currentLogger = autoDiscardingLoggingAdapter;
+ mdcEntries.forEach(mdcEntry -> currentLogger.putMdcEntry(mdcEntry.getKey(), mdcEntry.getValueOrNull()));
+ return this;
+ }
+
@Override
public DefaultDittoDiagnosticLoggingAdapter withMdcEntry(final MdcEntry mdcEntry,
final Seq furtherMdcEntries) {
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoLogger.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoLogger.java
index 86e9461372..cafb20b2e1 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoLogger.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoLogger.java
@@ -14,6 +14,9 @@
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;
+import java.util.Collection;
+import java.util.Map;
+
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
@@ -60,6 +63,11 @@ public DefaultDittoLogger withCorrelationId(@Nullable final CharSequence correla
return this;
}
+ @Override
+ public DefaultDittoLogger withCorrelationId(@Nullable final Map headers) {
+ return withMdcEntries(CommonMdcEntryKey.extractMdcEntriesFromHeaders(headers));
+ }
+
@Override
public DefaultDittoLogger withCorrelationId(@Nullable final WithDittoHeaders withDittoHeaders) {
return withCorrelationId(null != withDittoHeaders ? withDittoHeaders.getDittoHeaders() : null);
@@ -67,7 +75,7 @@ public DefaultDittoLogger withCorrelationId(@Nullable final WithDittoHeaders wit
@Override
public DefaultDittoLogger withCorrelationId(@Nullable final DittoHeaders dittoHeaders) {
- return withCorrelationId(null != dittoHeaders ? dittoHeaders.getCorrelationId().orElse(null) : null);
+ return withCorrelationId(null != dittoHeaders ? dittoHeaders : Map.of());
}
@Override
@@ -77,17 +85,6 @@ public DefaultDittoLogger setCorrelationId(@Nullable final CharSequence correlat
return this;
}
- @Override
- public DefaultDittoLogger setCorrelationId(final WithDittoHeaders withDittoHeaders) {
- return setCorrelationId(checkNotNull(withDittoHeaders, "withDittoHeaders").getDittoHeaders());
- }
-
- @Override
- public DefaultDittoLogger setCorrelationId(final DittoHeaders dittoHeaders) {
- checkNotNull(dittoHeaders, "dittoHeaders");
- return setCorrelationId(dittoHeaders.getCorrelationId().orElse(null));
- }
-
@Override
public void discardCorrelationId() {
currentLogger.discardCorrelationId();
@@ -141,6 +138,15 @@ public DefaultDittoLogger withMdcEntry(final MdcEntry mdcEntry, final MdcEntry..
return this;
}
+ @Override
+ public DefaultDittoLogger withMdcEntries(final Collection mdcEntries) {
+ checkNotNull(mdcEntries, "mdcEntries");
+
+ currentLogger = autoClosingSlf4jLogger;
+ mdcEntries.forEach(mdcEntry -> currentLogger.putMdcEntry(mdcEntry.getKey(), mdcEntry.getValueOrNull()));
+ return this;
+ }
+
@Override
public DefaultDittoLogger removeMdcEntry(final CharSequence key) {
currentLogger.removeMdcEntry(key);
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DittoLogger.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DittoLogger.java
index 12ec9a5d23..0566d7ed7c 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DittoLogger.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/DittoLogger.java
@@ -12,6 +12,8 @@
*/
package org.eclipse.ditto.internal.utils.pekko.logging;
+import java.util.Map;
+
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
@@ -95,48 +97,28 @@ public interface DittoLogger extends Logger, WithMdcEntry {
DittoLogger withCorrelationId(@Nullable CharSequence correlationId);
/**
- * Derives the correlation ID from the given WithDittoHeaders for the subsequent log operation.
- *
- * @param withDittoHeaders provides DittoHeaders which might contain the correlation ID to be put to the MDC.
- * @return this DittoLogger instance to allow method chaining.
- */
- DittoLogger withCorrelationId(@Nullable WithDittoHeaders withDittoHeaders);
-
- /**
- * Obtains the correlation ID from the given DittoHeaders for the subsequent log operation.
- *
- * @param dittoHeaders might contain the correlation ID to be put to the MDC.
- * @return this DittoLogger instance to allow method chaining.
- */
- DittoLogger withCorrelationId(@Nullable DittoHeaders dittoHeaders);
-
- /**
- * Sets the given correlation ID for all subsequent log operations until it gets manually discarded.
+ * Obtains the correlation ID from the given Headers for the subsequent log operation.
*
- * @param correlationId the correlation ID to be put to the MDC.
+ * @param headers might contain the correlation ID to be put to the MDC.
* @return this DittoLogger instance to allow method chaining.
*/
- AutoCloseableSlf4jLogger setCorrelationId(@Nullable CharSequence correlationId);
+ DittoLogger withCorrelationId(@Nullable Map headers);
/**
- * Derives the correlation ID from the given WithDittoHeaders for all subsequent log operations until it gets
- * manually discarded.
+ * Derives the correlation ID from the given WithDittoHeaders for the subsequent log operation.
*
* @param withDittoHeaders provides DittoHeaders which might contain the correlation ID to be put to the MDC.
* @return this DittoLogger instance to allow method chaining.
- * @throws NullPointerException if {@code withDittoHeaders} is {@code null}.
*/
- AutoCloseableSlf4jLogger setCorrelationId(WithDittoHeaders withDittoHeaders);
+ DittoLogger withCorrelationId(@Nullable WithDittoHeaders withDittoHeaders);
/**
- * Obtains the correlation ID from the given DittoHeaders for all subsequent log operations until it gets manually
- * discarded.
+ * Obtains the correlation ID from the given DittoHeaders for the subsequent log operation.
*
* @param dittoHeaders might contain the correlation ID to be put to the MDC.
* @return this DittoLogger instance to allow method chaining.
- * @throws NullPointerException if {@code dittoHeaders} is {@code null}.
*/
- AutoCloseableSlf4jLogger setCorrelationId(DittoHeaders dittoHeaders);
+ DittoLogger withCorrelationId(@Nullable DittoHeaders dittoHeaders);
/**
* Removes the currently set correlation ID from the MDC.
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLogger.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLogger.java
index 631519a006..72c518d47e 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLogger.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLogger.java
@@ -15,6 +15,7 @@
import static org.eclipse.ditto.base.model.common.ConditionChecker.argumentNotEmpty;
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -363,6 +364,11 @@ public ImmutableDittoLogger withCorrelationId(@Nullable final CharSequence corre
return withMdcEntry(CommonMdcEntryKey.CORRELATION_ID, correlationId);
}
+ @Override
+ public ImmutableDittoLogger withCorrelationId(@Nullable final Map headers) {
+ return withMdcEntries(CommonMdcEntryKey.extractMdcEntriesFromHeaders(headers));
+ }
+
@Override
public ImmutableDittoLogger withCorrelationId(@Nullable final WithDittoHeaders withDittoHeaders) {
return withCorrelationId(null != withDittoHeaders ? withDittoHeaders.getDittoHeaders() : null);
@@ -370,7 +376,7 @@ public ImmutableDittoLogger withCorrelationId(@Nullable final WithDittoHeaders w
@Override
public ImmutableDittoLogger withCorrelationId(@Nullable final DittoHeaders dittoHeaders) {
- return withCorrelationId(null != dittoHeaders ? dittoHeaders.getCorrelationId().orElse(null) : null);
+ return withCorrelationId(null != dittoHeaders ? dittoHeaders : Map.of());
}
@Override
@@ -467,6 +473,16 @@ public ImmutableDittoLogger withMdcEntry(final MdcEntry mdcEntry, final MdcEntry
return new ImmutableDittoLogger(plainSlf4jLogger, newLocalMdc);
}
+ @Override
+ public ImmutableDittoLogger withMdcEntries(final Collection mdcEntries) {
+ checkNotNull(mdcEntries, "mdcEntries");
+
+ final Map newLocalMdc = copyLocalMdc();
+ mdcEntries.forEach(mdcEntry -> newLocalMdc.put(mdcEntry.getKey(), mdcEntry.getValueOrNull()));
+
+ return new ImmutableDittoLogger(plainSlf4jLogger, newLocalMdc);
+ }
+
@Override
public ImmutableDittoLogger removeMdcEntry(final CharSequence key) {
validateMdcEntryKey(key, "key");
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLoggingAdapter.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLoggingAdapter.java
index d68b07fd14..68655198d2 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLoggingAdapter.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ImmutableDittoLoggingAdapter.java
@@ -15,6 +15,7 @@
import static org.eclipse.ditto.base.model.common.ConditionChecker.argumentNotEmpty;
import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
@@ -75,14 +76,19 @@ public ImmutableDittoLoggingAdapter withCorrelationId(@Nullable final CharSequen
return withMdcEntry(CommonMdcEntryKey.CORRELATION_ID, correlationId);
}
+ @Override
+ public ImmutableDittoLoggingAdapter withCorrelationId(@Nullable final Map headers) {
+ return withMdcEntries(CommonMdcEntryKey.extractMdcEntriesFromHeaders(headers));
+ }
+
@Override
public ImmutableDittoLoggingAdapter withCorrelationId(@Nullable final WithDittoHeaders withDittoHeaders) {
- return withCorrelationId(null != withDittoHeaders ? withDittoHeaders.getDittoHeaders() : null);
+ return withCorrelationId(withDittoHeaders != null ? withDittoHeaders.getDittoHeaders() : null);
}
@Override
public ImmutableDittoLoggingAdapter withCorrelationId(@Nullable final DittoHeaders dittoHeaders) {
- return withCorrelationId(null != dittoHeaders ? dittoHeaders.getCorrelationId().orElse(null) : null);
+ return withCorrelationId(null != dittoHeaders ? dittoHeaders : Map.of());
}
@Override
@@ -187,6 +193,16 @@ public ImmutableDittoLoggingAdapter withMdcEntry(final MdcEntry mdcEntry, final
return newInstance(diagnosticLoggingAdapterFactory, mdcCopy);
}
+ @Override
+ public ImmutableDittoLoggingAdapter withMdcEntries(final Collection mdcEntries) {
+ checkNotNull(mdcEntries, "mdcEntries");
+
+ final Map newLocalMdc = getCopyOfMdc();
+ mdcEntries.forEach(mdcEntry -> newLocalMdc.put(mdcEntry.getKey(), mdcEntry.getValueOrNull()));
+
+ return newInstance(diagnosticLoggingAdapterFactory, newLocalMdc);
+ }
+
@Override
public ImmutableDittoLoggingAdapter withMdcEntry(final MdcEntry mdcEntry, final MdcEntry... furtherMdcEntries) {
checkNotNull(mdcEntry, "mdcEntry");
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLogger.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLogger.java
index 8bf408288e..0fa0484bda 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLogger.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLogger.java
@@ -12,6 +12,8 @@
*/
package org.eclipse.ditto.internal.utils.pekko.logging;
+import java.util.Map;
+
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
@@ -76,6 +78,16 @@ public interface ThreadSafeDittoLogger extends Logger, WithMdcEntry headers);
+
/**
* Derives the correlation ID from the given WithDittoHeaders for the log operations on the returned logger.
* If no or an empty correlation ID can be derived, this method has the same effect like
diff --git a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/WithMdcEntry.java b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/WithMdcEntry.java
index 74d5b1fb8e..14bb8376d6 100644
--- a/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/WithMdcEntry.java
+++ b/internal/utils/pekko/src/main/java/org/eclipse/ditto/internal/utils/pekko/logging/WithMdcEntry.java
@@ -12,6 +12,8 @@
*/
package org.eclipse.ditto.internal.utils.pekko.logging;
+import java.util.Collection;
+
import javax.annotation.Nullable;
import org.slf4j.Logger;
@@ -84,6 +86,14 @@ L withMdcEntries(CharSequence k1, @Nullable CharSequence v1, CharSequence k2, @N
*/
L withMdcEntry(MdcEntry mdcEntry, MdcEntry... furtherMdcEntries);
+ /**
+ * Puts the given entries to the MDC of this logger.
+ *
+ * @return this or a new logger instance for method chaining.
+ * @throws NullPointerException if any argument is {@code null}.
+ */
+ L withMdcEntries(Collection mdcEntries);
+
/**
* Removes the diagnostic context value identified by the specified key.
* This method does nothing if there is no previous value associated with the specified key.
diff --git a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/DittoDiagnosticLoggingAdapter.scala b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/DittoDiagnosticLoggingAdapter.scala
index bdab0b8e18..6718362e0a 100644
--- a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/DittoDiagnosticLoggingAdapter.scala
+++ b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/DittoDiagnosticLoggingAdapter.scala
@@ -14,6 +14,7 @@ package org.eclipse.ditto.internal.utils.pekko.logging
import org.eclipse.ditto.base.model.headers.{DittoHeaders, WithDittoHeaders}
+import java.util
import javax.annotation.Nullable
import javax.annotation.concurrent.NotThreadSafe
import scala.annotation.varargs
@@ -62,6 +63,13 @@ abstract class DittoDiagnosticLoggingAdapter extends AbstractDiagnosticLoggingAd
*/
def withCorrelationId(@Nullable correlationId: CharSequence): DittoDiagnosticLoggingAdapter
+ /** Obtains the correlation ID from the given headers for the subsequent log operation.
+ *
+ * @param headers might contain the correlation ID to be put to the MDC.
+ * @return this DittoLogger instance to allow method chaining.
+ */
+ def withCorrelationId(@Nullable headers: util.Map[String, String]): DittoDiagnosticLoggingAdapter
+
/** Derives the correlation ID from the given WithDittoHeaders for the subsequent log operation.
*
* @param withDittoHeaders provides DittoHeaders which might contain the correlation ID to be put to the MDC.
@@ -76,31 +84,6 @@ abstract class DittoDiagnosticLoggingAdapter extends AbstractDiagnosticLoggingAd
*/
def withCorrelationId(@Nullable dittoHeaders: DittoHeaders): DittoDiagnosticLoggingAdapter
- /** Sets the given correlation ID for all subsequent log operations until it gets manually discarded.
- *
- * @param correlationId the correlation ID to be put to the MDC.
- * @return this logger instance to allow method chaining.
- */
- def setCorrelationId(@Nullable correlationId: CharSequence): DittoDiagnosticLoggingAdapter
-
- /** Derives the correlation ID from the given WithDittoHeaders for all subsequent log operations until it gets
- * manually discarded.
- *
- * @param withDittoHeaders provides DittoHeaders which might contain the correlation ID to be put to the MDC.
- * @return this logger instance to allow method chaining.
- * @throws NullPointerException if `withDittoHeaders` is `null`.
- */
- def setCorrelationId(withDittoHeaders: WithDittoHeaders): DittoDiagnosticLoggingAdapter
-
- /** Obtains the correlation ID from the given DittoHeaders for all subsequent log operations until it gets manually
- * discarded.
- *
- * @param dittoHeaders might contain the correlation ID to be put to the MDC.
- * @return this logger instance to allow method chaining.
- * @throws NullPointerException if `dittoHeaders` is `null`.
- */
- def setCorrelationId(dittoHeaders: DittoHeaders): DittoDiagnosticLoggingAdapter
-
/** Removes the correlation ID from the MDC for all subsequent log operations. */
def discardCorrelationId(): Unit
@@ -164,14 +147,6 @@ abstract class DittoDiagnosticLoggingAdapter extends AbstractDiagnosticLoggingAd
*/
def discardMdcEntry(key: CharSequence): Unit
- /** Sets the specified diagnostic context values as identified by the specified keys to this logger's MDC for all
- * subsequent log operations until it gets manually discarded.
- *
- * @return this logger instance to allow method chaining.
- * @throws NullPointerException if any argument is `null`.
- */
- @annotation.varargs def setMdcEntry(mdcEntry: MdcEntry, furtherMdcEntries: MdcEntry*): DittoDiagnosticLoggingAdapter
-
/** Message template with > 4 replacement arguments. */
@varargs def error(throwable: Throwable, template: String, arg1: Any, arg2: Any, arg3: Any, arg4: Any, moreArgs: Any*): Unit = {
if (isErrorEnabled) {
diff --git a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/MdcEntrySettable.scala b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/MdcEntrySettable.scala
index 0d2dde2344..4b19fc0227 100644
--- a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/MdcEntrySettable.scala
+++ b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/MdcEntrySettable.scala
@@ -12,6 +12,7 @@
*/
package org.eclipse.ditto.internal.utils.pekko.logging
+import java.util
import javax.annotation.Nullable
/** This trait defines the means to put and remove entries to or from the MDC of a logger.
@@ -78,6 +79,14 @@ trait MdcEntrySettable[L] {
*/
@annotation.varargs def withMdcEntry(mdcEntry: MdcEntry, furtherMdcEntries: MdcEntry*): L
+ /** Puts the given entries to the MDC of this logger.
+ *
+ * @param mdcEntries the MDC entries to set.
+ * @return this or a new logger instance for method chaining.
+ * @throws NullPointerException if any argument is `null`.
+ */
+ def withMdcEntries(mdcEntries: util.Collection[MdcEntry]): L
+
/** Removes the diagnostic context value identified by the specified key.
* This method does nothing if there is no previous value associated with the specified key.
*
diff --git a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLoggingAdapter.scala b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLoggingAdapter.scala
index 89a578601c..3870820a24 100644
--- a/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLoggingAdapter.scala
+++ b/internal/utils/pekko/src/main/scala/org/eclipse/ditto/internal/utils/pekko/logging/ThreadSafeDittoLoggingAdapter.scala
@@ -15,6 +15,7 @@ package org.eclipse.ditto.internal.utils.pekko.logging
import org.apache.pekko.event.LoggingAdapter
import org.eclipse.ditto.base.model.headers.{DittoHeaders, WithDittoHeaders}
+import java.util
import javax.annotation.Nullable
import javax.annotation.concurrent.ThreadSafe
@@ -77,6 +78,14 @@ abstract class ThreadSafeDittoLoggingAdapter extends LoggingAdapter
*/
def withCorrelationId(@Nullable correlationId: CharSequence): ThreadSafeDittoLoggingAdapter
+ /** Obtains the correlation ID from the given headers for the log operations on the returned logger.
+ *
+ * @param headers might contain the correlation ID to be put to the MDC.
+ * @return a ThreadSafeDittoLoggingAdapter which appends the derived correlation ID to all of its log operations.
+ * @see #withCorrelationId(DittoHeaders)
+ */
+ def withCorrelationId(@Nullable headers: util.Map[String, String]): ThreadSafeDittoLoggingAdapter
+
/** Derives the correlation ID from the given WithDittoHeaders for the log operations on the returned logger.
* If no or an empty correlation ID can be derived, this method has the same effect like
* [[ThreadSafeDittoLoggingAdapter discardCorrelationId()]].
diff --git a/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultAutoCloseableSlf4jLoggerTest.java b/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultAutoCloseableSlf4jLoggerTest.java
index 93141e4998..d8e4e6f846 100644
--- a/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultAutoCloseableSlf4jLoggerTest.java
+++ b/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultAutoCloseableSlf4jLoggerTest.java
@@ -132,7 +132,7 @@ public void logDebugAndWarnWithTwoMdcValuesThenClose() {
entry(CORRELATION_ID_KEY, correlationId), entry(CONNECTION_ID_KEY, connectionId));
softly.assertThat(mdcObserver.getAllRemovedKeys())
.as("Removed MDC entries")
- .containsExactly(CORRELATION_ID_KEY, CONNECTION_ID_KEY);
+ .contains(CORRELATION_ID_KEY, CONNECTION_ID_KEY);
}
@Test
diff --git a/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapterTest.java b/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapterTest.java
index adffaae9c8..20b8ac1d76 100644
--- a/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapterTest.java
+++ b/internal/utils/pekko/src/test/java/org/eclipse/ditto/internal/utils/pekko/logging/DefaultDittoDiagnosticLoggingAdapterTest.java
@@ -170,20 +170,6 @@ public void withTwoMdcEntriesLogWarning() {
Mockito.verify(plainLoggingAdapter).setMDC(Map.of());
}
- @Test
- public void putNothingToMdcAndDoNotLogAsInfoIsDisabled() {
- final String msg = "Foo!";
- Mockito.when(plainLoggingAdapter.isInfoEnabled()).thenReturn(false);
-
- final DefaultDittoDiagnosticLoggingAdapter underTest =
- DefaultDittoDiagnosticLoggingAdapter.of(plainLoggingAdapter, LOGGER_NAME);
- underTest.setCorrelationId(getCorrelationId());
- underTest.info(msg);
-
- Mockito.verify(plainLoggingAdapter, Mockito.times(0)).info(msg);
- Mockito.verify(plainLoggingAdapter, Mockito.times(0)).setMDC(Mockito.anyMap());
- }
-
@Test
public void logDebugAndWarnWithTwoMdcValuesThenDiscardMdcEntries() {
final String correlationId = getCorrelationId();
@@ -246,62 +232,6 @@ public void removeMdcEntryViaNullValue() {
Mockito.verify(plainLoggingAdapter).setMDC(Map.of(CONNECTION_ID_KEY, connectionId));
}
- @Test
- public void setCorrelationIdLogErrorDoNotDiscard() {
- final String correlationId = getCorrelationId();
- final String msg = "Foo!";
- Mockito.when(plainLoggingAdapter.isErrorEnabled()).thenReturn(true);
-
- final DefaultDittoDiagnosticLoggingAdapter underTest =
- DefaultDittoDiagnosticLoggingAdapter.of(plainLoggingAdapter, LOGGER_NAME);
- underTest.setCorrelationId(correlationId);
- underTest.error(msg);
-
- Mockito.verify(plainLoggingAdapter).isErrorEnabled();
- Mockito.verify(plainLoggingAdapter).getMDC();
- Mockito.verify(plainLoggingAdapter).setMDC(Map.of(CORRELATION_ID_KEY, correlationId));
- Mockito.verify(plainLoggingAdapter).notifyError(msg);
- Mockito.verifyNoMoreInteractions(plainLoggingAdapter);
- }
-
- @Test
- public void setCorrelationIdLogErrorDoNotClose() {
- final String correlationId = getCorrelationId();
- final String msg = "Foo!";
- Mockito.when(plainLoggingAdapter.isErrorEnabled()).thenReturn(true);
-
- final DefaultDittoDiagnosticLoggingAdapter underTest =
- DefaultDittoDiagnosticLoggingAdapter.of(plainLoggingAdapter, LOGGER_NAME);
- underTest.setCorrelationId(correlationId);
- underTest.error(msg);
-
- Mockito.verify(plainLoggingAdapter).isErrorEnabled();
- Mockito.verify(plainLoggingAdapter).getMDC();
- Mockito.verify(plainLoggingAdapter).setMDC(Map.of(CORRELATION_ID_KEY, correlationId));
- Mockito.verify(plainLoggingAdapter).notifyError(msg);
- Mockito.verifyNoMoreInteractions(plainLoggingAdapter);
- }
-
- @Test
- public void setCorrelationIdLogInfoThenDiscardCorrelationId() {
- final String correlationId = getCorrelationId();
- final String msg1 = "Foo!";
- final String msg2 = "No correlation ID in MDC.";
- Mockito.when(plainLoggingAdapter.isInfoEnabled()).thenReturn(true);
-
- final DefaultDittoDiagnosticLoggingAdapter underTest =
- DefaultDittoDiagnosticLoggingAdapter.of(plainLoggingAdapter, LOGGER_NAME);
- underTest.setCorrelationId(correlationId);
- underTest.info(msg1);
- underTest.discardCorrelationId();
- underTest.info(msg2);
-
- Mockito.verify(plainLoggingAdapter).setMDC(Map.of(CORRELATION_ID_KEY, correlationId));
- Mockito.verify(plainLoggingAdapter).notifyInfo(msg1);
- Mockito.verify(plainLoggingAdapter).setMDC(Map.of());
- Mockito.verify(plainLoggingAdapter).notifyInfo(msg2);
- }
-
@Test
public void logMoreThan4LoggingArgsError() {
final String template = "one: {}, two: {}, three: {}, four: {}, five: {}, six: {}";
diff --git a/internal/utils/persistence/src/test/resources/logback-test.xml b/internal/utils/persistence/src/test/resources/logback-test.xml
index 01dc8d2353..95a966715a 100644
--- a/internal/utils/persistence/src/test/resources/logback-test.xml
+++ b/internal/utils/persistence/src/test/resources/logback-test.xml
@@ -5,14 +5,14 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
System.err
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
ERROR
diff --git a/internal/utils/tracing/src/main/java/org/eclipse/ditto/internal/utils/tracing/span/KamonHttpContextPropagation.java b/internal/utils/tracing/src/main/java/org/eclipse/ditto/internal/utils/tracing/span/KamonHttpContextPropagation.java
index 9fac417620..aa68cf1c96 100644
--- a/internal/utils/tracing/src/main/java/org/eclipse/ditto/internal/utils/tracing/span/KamonHttpContextPropagation.java
+++ b/internal/utils/tracing/src/main/java/org/eclipse/ditto/internal/utils/tracing/span/KamonHttpContextPropagation.java
@@ -99,7 +99,7 @@ public Context getContextFromHeaders(final Map headers) {
public Map propagateContextToHeaders(final Context context, final Map headers) {
checkNotNull(context, "context");
final var result = getMutableCopyOfMap(checkNotNull(headers, "headers"));
- propagation.write(context, result::put);
+ propagation.write(context, result::putIfAbsent);
return result;
}
diff --git a/policies/service/src/main/java/org/eclipse/ditto/policies/service/persistence/actors/announcements/PolicyAnnouncementAcknowledgementAggregatorActor.java b/policies/service/src/main/java/org/eclipse/ditto/policies/service/persistence/actors/announcements/PolicyAnnouncementAcknowledgementAggregatorActor.java
index e2db7b7556..06bb50ba5b 100644
--- a/policies/service/src/main/java/org/eclipse/ditto/policies/service/persistence/actors/announcements/PolicyAnnouncementAcknowledgementAggregatorActor.java
+++ b/policies/service/src/main/java/org/eclipse/ditto/policies/service/persistence/actors/announcements/PolicyAnnouncementAcknowledgementAggregatorActor.java
@@ -64,7 +64,7 @@ private PolicyAnnouncementAcknowledgementAggregatorActor(final PolicyAnnouncemen
aggregator = AcknowledgementAggregator.getInstance(policyAnnouncement.getEntityId(), correlationId, timeout,
HeaderTranslator.empty());
aggregator.addAcknowledgementRequests(acknowledgementRequests);
- log.withCorrelationId(correlationId)
+ log.withCorrelationId(dittoHeaders)
.info("Starting to wait for all requested acknowledgements <{}> for a maximum duration of <{}>.",
acknowledgementRequests, timeout);
}
diff --git a/policies/service/src/main/resources/logback.xml b/policies/service/src/main/resources/logback.xml
index 11598d115c..a203eb8171 100755
--- a/policies/service/src/main/resources/logback.xml
+++ b/policies/service/src/main/resources/logback.xml
@@ -16,14 +16,14 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
System.err
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
ERROR
diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/PolicyIdReferencePlaceholderResolver.java b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/PolicyIdReferencePlaceholderResolver.java
index 3b1e3335ec..8238bdcbf8 100644
--- a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/PolicyIdReferencePlaceholderResolver.java
+++ b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/PolicyIdReferencePlaceholderResolver.java
@@ -23,7 +23,6 @@
import org.eclipse.ditto.base.model.exceptions.DittoInternalErrorException;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
-import org.eclipse.ditto.internal.utils.pekko.logging.AutoCloseableSlf4jLogger;
import org.eclipse.ditto.internal.utils.pekko.logging.DittoLogger;
import org.eclipse.ditto.internal.utils.pekko.logging.DittoLoggerFactory;
import org.eclipse.ditto.internal.utils.cacheloaders.AskWithRetry;
@@ -86,15 +85,14 @@ public CompletionStage resolve(final ReferencePlaceholder referencePlace
final var resolveEntityReferenceStrategy =
supportedEntityTypesToActionMap.get(referencePlaceholder.getReferencedEntityType());
- try (final AutoCloseableSlf4jLogger logger = LOGGER.setCorrelationId(dittoHeaders)) {
- if (null == resolveEntityReferenceStrategy) {
- final String referencedEntityType = referencePlaceholder.getReferencedEntityType().name();
- logger.info("Could not find a placeholder replacement strategy for entity type <{}> in supported" +
- " entity types: {}", referencedEntityType, supportedEntityTypeNames);
- throw notSupportedException(referencedEntityType, dittoHeaders);
- }
- logger.debug("Will resolve entity reference for placeholder: <{}>", referencePlaceholder);
+ final DittoLogger logger = LOGGER.withCorrelationId(dittoHeaders);
+ if (null == resolveEntityReferenceStrategy) {
+ final String referencedEntityType = referencePlaceholder.getReferencedEntityType().name();
+ logger.info("Could not find a placeholder replacement strategy for entity type <{}> in supported" +
+ " entity types: {}", referencedEntityType, supportedEntityTypeNames);
+ throw notSupportedException(referencedEntityType, dittoHeaders);
}
+ logger.debug("Will resolve entity reference for placeholder: <{}>", referencePlaceholder);
return resolveEntityReferenceStrategy.handleEntityPolicyIdReference(referencePlaceholder, dittoHeaders);
}
diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java
index 62639c1a91..85067616c2 100644
--- a/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java
+++ b/things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java
@@ -231,7 +231,7 @@ private CompletionStage> loadPolicyEnforcerForCreateThi
return invalidatable.invalidate(PolicyTag.of(policy.getEntityId().get(),
policy.getRevision().get().toLong()), correlationId, askWithRetryConfig.getAskTimeout())
.thenApply(bool -> {
- log.withCorrelationId(correlationId)
+ log.withCorrelationId(createThing)
.debug("PolicyEnforcerCache invalidated. Previous entity was present: {}",
bool);
return policy;
diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/SupervisorInlinePolicyEnrichment.java b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/SupervisorInlinePolicyEnrichment.java
index c2edcce263..32145855e5 100644
--- a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/SupervisorInlinePolicyEnrichment.java
+++ b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/SupervisorInlinePolicyEnrichment.java
@@ -18,8 +18,6 @@
import java.util.UUID;
import java.util.concurrent.CompletionStage;
-import javax.annotation.Nullable;
-
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.headers.WithDittoHeaders;
@@ -189,21 +187,20 @@ private CompletionStage> retrieveInlinedPolicyF
if (response instanceof RetrievePolicyResponse retrievePolicyResponse) {
return Optional.of(retrievePolicyResponse);
} else {
- log.withCorrelationId(getCorrelationIdOrNull(response, retrievePolicy))
+ log.withCorrelationId(getEffectiveHeaders(response, retrievePolicy))
.info("No authorized response when retrieving inlined policy <{}> for thing <{}>: {}",
retrievePolicy.getEntityId(), thingId, response);
return Optional.empty();
}
}
).exceptionally(error -> {
- log.withCorrelationId(getCorrelationIdOrNull(error, retrievePolicy))
+ log.withCorrelationId(getEffectiveHeaders(error, retrievePolicy))
.error(error, "Retrieving inlined policy after RetrieveThing");
return Optional.empty();
});
}
- @Nullable
- private static CharSequence getCorrelationIdOrNull(final Object signal, final WithDittoHeaders fallBackSignal) {
+ private static DittoHeaders getEffectiveHeaders(final Object signal, final WithDittoHeaders fallBackSignal) {
final WithDittoHeaders withDittoHeaders;
if (isWithDittoHeaders(signal)) {
@@ -211,8 +208,7 @@ private static CharSequence getCorrelationIdOrNull(final Object signal, final Wi
} else {
withDittoHeaders = fallBackSignal;
}
- final var dittoHeaders = withDittoHeaders.getDittoHeaders();
- return dittoHeaders.getCorrelationId().orElse(null);
+ return withDittoHeaders.getDittoHeaders();
}
private static boolean isWithDittoHeaders(final Object o) {
diff --git a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/ThingSupervisorActor.java b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/ThingSupervisorActor.java
index 76b8db7835..6cd73ae28a 100755
--- a/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/ThingSupervisorActor.java
+++ b/things/service/src/main/java/org/eclipse/ditto/things/service/persistence/actors/ThingSupervisorActor.java
@@ -355,7 +355,7 @@ private void handleRollbackCreatedPolicy(final RollbackCreatedPolicy rollback) {
final String correlationId = rollback.initialCommand().getDittoHeaders().getCorrelationId()
.orElse("unexpected:" + UUID.randomUUID());
if (policyCreatedEvent != null) {
- log.withCorrelationId(correlationId)
+ log.withCorrelationId(rollback.initialCommand())
.warning("Rolling back created policy as consequence of received RollbackCreatedPolicy " +
"message: {}", rollback);
final DittoHeaders dittoHeaders = DittoHeaders.newBuilder()
@@ -366,19 +366,20 @@ private void handleRollbackCreatedPolicy(final RollbackCreatedPolicy rollback) {
AskWithRetry.askWithRetry(policiesShardRegion, deletePolicy,
enforcementConfig.getAskWithRetryConfig(),
getContext().system(), response -> {
- log.withCorrelationId(correlationId)
+ log.withCorrelationId(rollback.initialCommand())
.info("Policy <{}> deleted after rolling back it's creation. " +
"Policies shard region response: <{}>", deletePolicy.getEntityId(), response);
rollback.completeInitialResponse();
return response;
}).exceptionally(throwable -> {
- log.withCorrelationId(correlationId).error(throwable, "Failed to rollback Policy Create");
+ log.withCorrelationId(rollback.initialCommand())
+ .error(throwable, "Failed to rollback Policy Create");
rollback.completeInitialResponse();
return null;
});
} else {
- log.withCorrelationId(correlationId)
+ log.withCorrelationId(rollback.initialCommand())
.debug("Not initiating policy rollback as none was created.");
rollback.completeInitialResponse();
}
diff --git a/things/service/src/main/resources/logback.xml b/things/service/src/main/resources/logback.xml
index 49aa8b4f82..4f6086340b 100755
--- a/things/service/src/main/resources/logback.xml
+++ b/things/service/src/main/resources/logback.xml
@@ -16,14 +16,14 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
System.err
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
ERROR
diff --git a/things/service/src/test/resources/logback-test.xml b/things/service/src/test/resources/logback-test.xml
index 129c7339d0..8f07693a11 100644
--- a/things/service/src/test/resources/logback-test.xml
+++ b/things/service/src/test/resources/logback-test.xml
@@ -20,7 +20,7 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20‚} - %msg%n%rEx
+ %date{ISO8601} %-5level [%X{correlation-id}] %logger{20‚} - %msg%n%rEx
diff --git a/thingsearch/service/src/main/resources/logback.xml b/thingsearch/service/src/main/resources/logback.xml
index 9874fe302b..bf25257f5e 100755
--- a/thingsearch/service/src/main/resources/logback.xml
+++ b/thingsearch/service/src/main/resources/logback.xml
@@ -16,14 +16,14 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
System.err
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}][%X{traceparent-trace-id}] %logger{20} %X{pekkoSource} - %msg%n
ERROR
diff --git a/thingsearch/service/src/test/resources/logback-test.xml b/thingsearch/service/src/test/resources/logback-test.xml
index 9ab0e39ae3..63e44eb30e 100644
--- a/thingsearch/service/src/test/resources/logback-test.xml
+++ b/thingsearch/service/src/test/resources/logback-test.xml
@@ -17,14 +17,14 @@
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
System.err
- %date{ISO8601} %-5level [%X{x-correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
+ %date{ISO8601} %-5level [%X{correlation-id}] %logger{20} %X{pekkoSource} - %msg%n
ERROR