From fbe7e0db7cc591990c379ac1516be7a4433fe01c Mon Sep 17 00:00:00 2001 From: "Brittany Plummer (bp896r)" Date: Wed, 13 Nov 2019 10:58:36 -0500 Subject: Split InvocationID into two MDC values Issue-ID: LOG-1187 Change-Id: Ice156a1bb4665f747e46bc5305be547800f10c4c Signed-off-by: Brittany Plummer (bp896r) --- reference/logging-demo/pom.xml | 2 +- reference/logging-docker-root/pom.xml | 2 +- .../logging-filter/logging-filter-base/pom.xml | 2 +- .../filter/base/AbstractMetricLogFilter.java | 9 +++++++-- .../org/onap/logging/filter/base/MDCSetup.java | 11 ++--------- .../org/onap/logging/filter/base/MDCSetupTest.java | 22 ++++------------------ .../filter/base/MetricLogClientFilterTest.java | 8 +++++++- .../logging-filter/logging-filter-spring/pom.xml | 2 +- .../filter/spring/SpringClientFilterTest.java | 1 - reference/logging-filter/pom.xml | 2 +- reference/logging-kubernetes/pom.xml | 2 +- reference/logging-library/pom.xml | 2 +- reference/logging-mock-service/pom.xml | 2 +- reference/logging-slf4j-demo/pom.xml | 2 +- reference/logging-slf4j/pom.xml | 2 +- .../onap/logging/ref/slf4j/ONAPLogConstants.java | 4 ++++ reference/pom.xml | 2 +- reference/provider/pom.xml | 2 +- 18 files changed, 36 insertions(+), 43 deletions(-) (limited to 'reference') diff --git a/reference/logging-demo/pom.xml b/reference/logging-demo/pom.xml index 1988407..8d0e8a3 100644 --- a/reference/logging-demo/pom.xml +++ b/reference/logging-demo/pom.xml @@ -3,7 +3,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-demo war diff --git a/reference/logging-docker-root/pom.xml b/reference/logging-docker-root/pom.xml index e52e2bb..5eb9b5d 100644 --- a/reference/logging-docker-root/pom.xml +++ b/reference/logging-docker-root/pom.xml @@ -4,7 +4,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-docker-root pom diff --git a/reference/logging-filter/logging-filter-base/pom.xml b/reference/logging-filter/logging-filter-base/pom.xml index cab541c..718441f 100644 --- a/reference/logging-filter/logging-filter-base/pom.xml +++ b/reference/logging-filter/logging-filter-base/pom.xml @@ -5,7 +5,7 @@ org.onap.logging-analytics logging-filter-parent - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-filter-base 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 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 } + 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); diff --git a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java index bdf8bd0..68b977d 100644 --- a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java +++ b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java @@ -116,28 +116,14 @@ public class MDCSetupTest extends MDCSetup { HashMap headers = new HashMap<>(); headers.put(ONAPLogConstants.Headers.INVOCATION_ID, invocationId); setInvocationId(new SimpleHashMap(headers)); - assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); } @Test public void setInvocationIdNoHeaderTest() { HashMap headers = new HashMap<>(); setInvocationId(new SimpleHashMap(headers)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - } - - @Test - public void setInvovationIdFromMDCTest() { - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, "7b77143c-9b50-410c-ac2f-05758a68e3e8"); - setInvocationIdFromMDC(); - assertEquals("7b77143c-9b50-410c-ac2f-05758a68e3e8", MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - } - - @Test - public void setInvocationIdFromMDCNoInvocationIdTest() { - setInvocationIdFromMDC(); - // InvocationId is set to a random UUID - assertNotNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); } @Test @@ -156,7 +142,7 @@ public class MDCSetupTest extends MDCSetup { @Test public void clearClientMDCsTest() { - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, "7b77143c-9b50-410c-ac2f-05758a68e3e9"); + MDC.put(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID, "7b77143c-9b50-410c-ac2f-05758a68e3e9"); MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, "Bad Gateway"); MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, "Bad Gateway"); MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, "502"); @@ -167,7 +153,7 @@ public class MDCSetupTest extends MDCSetup { MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, "2019-06-18T02:09:06.024Z"); clearClientMDCs(); - assertNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + assertNull(MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID)); assertNull(MDC.get(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION)); assertNull(MDC.get(ONAPLogConstants.MDCs.ERROR_CODE)); assertNull(MDC.get(ONAPLogConstants.MDCs.ERROR_DESC)); diff --git a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java index 3729e92..48da3fa 100644 --- a/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java +++ b/reference/logging-filter/logging-filter-base/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java @@ -57,7 +57,6 @@ public class MetricLogClientFilterTest { @Test public void setupHeadersTest() { - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, "8819bfb4-69d2-43fc-b0d6-81d2690533ea"); MultivaluedMap headers = new MultivaluedHashMap<>(); doReturn("0a908a5d-e774-4558-96ff-6edcbba65483").when(metricLogClientFilter).extractRequestID(); @@ -72,6 +71,13 @@ public class MetricLogClientFilterTest { assertEquals("UNKNOWN", headers.getFirst(ONAPLogConstants.Headers.PARTNER_NAME)); } + @Test + public void setInvocationIdTest() { + String invocationId = metricLogClientFilter.setInvocationId(); + + assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID)); + } + @Test public void setupMDCTest() throws URISyntaxException { // TODO ingest change from upstream diff --git a/reference/logging-filter/logging-filter-spring/pom.xml b/reference/logging-filter/logging-filter-spring/pom.xml index f26ab69..c8be7a9 100644 --- a/reference/logging-filter/logging-filter-spring/pom.xml +++ b/reference/logging-filter/logging-filter-spring/pom.xml @@ -5,7 +5,7 @@ org.onap.logging-analytics logging-filter-parent - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-filter-spring diff --git a/reference/logging-filter/logging-filter-spring/src/test/java/org/onap/logging/filter/spring/SpringClientFilterTest.java b/reference/logging-filter/logging-filter-spring/src/test/java/org/onap/logging/filter/spring/SpringClientFilterTest.java index c9925eb..4346fc1 100644 --- a/reference/logging-filter/logging-filter-spring/src/test/java/org/onap/logging/filter/spring/SpringClientFilterTest.java +++ b/reference/logging-filter/logging-filter-spring/src/test/java/org/onap/logging/filter/spring/SpringClientFilterTest.java @@ -120,7 +120,6 @@ public class SpringClientFilterTest extends SpringClientFilter { @Test public void setupHeadersTest() { - MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, "8819bfb4-69d2-43fc-b0d6-81d2690533ea"); MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, "0a908a5d-e774-4558-96ff-6edcbba65483"); HttpHeaders headers = new HttpHeaders(); diff --git a/reference/logging-filter/pom.xml b/reference/logging-filter/pom.xml index 27e6284..8f7e5fb 100644 --- a/reference/logging-filter/pom.xml +++ b/reference/logging-filter/pom.xml @@ -5,7 +5,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-filter-parent diff --git a/reference/logging-kubernetes/pom.xml b/reference/logging-kubernetes/pom.xml index 459d03e..5ae96a4 100644 --- a/reference/logging-kubernetes/pom.xml +++ b/reference/logging-kubernetes/pom.xml @@ -4,7 +4,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-kubernetes pom diff --git a/reference/logging-library/pom.xml b/reference/logging-library/pom.xml index 260ba13..cca06b6 100644 --- a/reference/logging-library/pom.xml +++ b/reference/logging-library/pom.xml @@ -3,7 +3,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-library jar diff --git a/reference/logging-mock-service/pom.xml b/reference/logging-mock-service/pom.xml index 1751aee..1da2c59 100644 --- a/reference/logging-mock-service/pom.xml +++ b/reference/logging-mock-service/pom.xml @@ -3,7 +3,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-mock-service jar diff --git a/reference/logging-slf4j-demo/pom.xml b/reference/logging-slf4j-demo/pom.xml index 9cbddd5..e630e5b 100644 --- a/reference/logging-slf4j-demo/pom.xml +++ b/reference/logging-slf4j-demo/pom.xml @@ -3,7 +3,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT .. logging-slf4j-demo diff --git a/reference/logging-slf4j/pom.xml b/reference/logging-slf4j/pom.xml index 6a3a6f3..756c86e 100644 --- a/reference/logging-slf4j/pom.xml +++ b/reference/logging-slf4j/pom.xml @@ -3,7 +3,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-slf4j logging-slf4j diff --git a/reference/logging-slf4j/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java b/reference/logging-slf4j/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java index 5357f40..48681e5 100644 --- a/reference/logging-slf4j/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java +++ b/reference/logging-slf4j/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java @@ -102,6 +102,10 @@ public final class ONAPLogConstants { /** MDC correlating messages for an invocation. */ public static final String INVOCATION_ID = "InvocationID"; + + public static final String SERVER_INVOCATION_ID = "ServerInvocationId"; + + public static final String CLIENT_INVOCATION_ID = "ClientInvocationId"; /** MDC correlating messages for a logical transaction. */ public static final String REQUEST_ID = "RequestID"; diff --git a/reference/pom.xml b/reference/pom.xml index 61ea63e..1f64c0e 100644 --- a/reference/pom.xml +++ b/reference/pom.xml @@ -4,7 +4,7 @@ org.onap.logging-analytics logging-analytics - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-reference pom diff --git a/reference/provider/pom.xml b/reference/provider/pom.xml index b9f98b6..3e517b7 100644 --- a/reference/provider/pom.xml +++ b/reference/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.logging-analytics logging-reference - 1.6.2-SNAPSHOT + 1.6.3-SNAPSHOT logging-provider pom -- cgit 1.2.3-korg