diff --git a/sbom.json b/sbom.json new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/redhat/exhort/impl/ExhortApi.java b/src/main/java/com/redhat/exhort/impl/ExhortApi.java index ddca1ef..c60448c 100644 --- a/src/main/java/com/redhat/exhort/impl/ExhortApi.java +++ b/src/main/java/com/redhat/exhort/impl/ExhortApi.java @@ -194,9 +194,10 @@ static HttpClient.Version getHttpVersion() { private String commonHookBeginning(boolean startOfApi) { if (startOfApi) { - generateClientRequestId(); + // generateClientRequestId(); if (debugLoggingIsNeeded()) { LOG.info("Start of exhort-java-api client"); + LOG.info(String.format("Starting time of API: %s", LocalDateTime.now())); } } else { if (Objects.isNull(getClientRequestId())) { diff --git a/src/main/java/com/redhat/exhort/impl/RequestManager.java b/src/main/java/com/redhat/exhort/impl/RequestManager.java index 1e40bea..973c012 100644 --- a/src/main/java/com/redhat/exhort/impl/RequestManager.java +++ b/src/main/java/com/redhat/exhort/impl/RequestManager.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; public class RequestManager { @@ -40,7 +41,18 @@ public synchronized void addClientTraceIdToRequest(String requestId) { } public synchronized void removeClientTraceIdFromRequest() { - requests.remove(concatenatedThreadId()); + String removedClientTraceId = requests.remove(concatenatedThreadId()); + // remove the traceId If it was propagated from parent Thread. + if (removedClientTraceId != null) { + Optional keyOfParent = + requests.entrySet().stream() + .filter(pair -> pair.getValue().equals(removedClientTraceId)) + .map(pair -> pair.getKey()) + .findFirst(); + if (keyOfParent.isPresent()) { + requests.remove(keyOfParent.get()); + } + } } public String getTraceIdOfRequest() {