diff options
author | 2019-11-13 10:58:36 -0500 | |
---|---|---|
committer | 2019-11-18 13:23:57 -0500 | |
commit | fbe7e0db7cc591990c379ac1516be7a4433fe01c (patch) | |
tree | b5fbde74c5232b18da1a59f2e9dc42a5deac882b /reference/logging-filter/logging-filter-base/src/main | |
parent | 1a764c63f3055107b5f490146b3ab2919012f0aa (diff) |
Split InvocationID into two MDC values
Issue-ID: LOG-1187
Change-Id: Ice156a1bb4665f747e46bc5305be547800f10c4c
Signed-off-by: Brittany Plummer (bp896r) <bp896r@att.com>
Diffstat (limited to 'reference/logging-filter/logging-filter-base/src/main')
2 files changed, 9 insertions, 11 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java index e4657a5..fabe8d2 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java @@ -67,7 +67,7 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders> protected void setupHeaders(Request clientRequest, RequestHeaders requestHeaders) { String requestId = extractRequestID(); - String invocationId = UUID.randomUUID().toString(); + String invocationId = setInvocationId(); addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.TRANSACTION_ID, requestId); @@ -78,12 +78,17 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders> } + protected String setInvocationId() { + String invocationId = UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID, invocationId); + return invocationId; + } + protected void setupMDC(Request request) { MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(request)); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); - setInvocationIdFromMDC(); if (MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY) == null) { String targetEntity = getTargetEntity(request); diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java index a900968..70cb46d 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/MDCSetup.java @@ -113,14 +113,7 @@ public class MDCSetup { String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID); if (invocationId == null || invocationId.isEmpty()) invocationId = UUID.randomUUID().toString(); - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); - } - - public void setInvocationIdFromMDC() { - String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID); - if (invocationId == null || invocationId.isEmpty()) - invocationId = UUID.randomUUID().toString(); - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); + MDC.put(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID, invocationId); } public void setMDCPartnerName(SimpleMap headers) { @@ -212,7 +205,7 @@ public class MDCSetup { } public void clearClientMDCs() { - MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID); + MDC.remove(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); |