diff options
6 files changed, 8 insertions, 0 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java index ce2f448..00285b6 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java @@ -52,6 +52,7 @@ public abstract class AbstractAuditLogFilter<GenericRequest, GenericResponse> ex protected void post(GenericResponse response) { try { + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); int responseCode = getResponseCode(response); setResponseStatusCode(responseCode); MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseCode)); 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 fabe8d2..16efdea 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 @@ -81,6 +81,7 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders> protected String setInvocationId() { String invocationId = UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID, invocationId); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); return invocationId; } 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 70cb46d..d600a2c 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 @@ -114,6 +114,7 @@ public class MDCSetup { if (invocationId == null || invocationId.isEmpty()) invocationId = UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID, invocationId); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); } public void setMDCPartnerName(SimpleMap headers) { 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 68b977d..6340ef1 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 @@ -117,6 +117,7 @@ public class MDCSetupTest extends MDCSetup { headers.put(ONAPLogConstants.Headers.INVOCATION_ID, invocationId); setInvocationId(new SimpleHashMap(headers)); assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); + assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); } @Test @@ -124,6 +125,7 @@ public class MDCSetupTest extends MDCSetup { HashMap<String, String> headers = new HashMap<>(); setInvocationId(new SimpleHashMap(headers)); assertNotNull(MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); } @Test 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 48da3fa..a0e1a2b 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 @@ -76,6 +76,7 @@ public class MetricLogClientFilterTest { String invocationId = metricLogClientFilter.setInvocationId(); assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID)); + assertEquals(invocationId, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); } @Test 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 4346fc1..042e6f1 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 @@ -131,6 +131,8 @@ public class SpringClientFilterTest extends SpringClientFilter { assertEquals("0a908a5d-e774-4558-96ff-6edcbba65483", headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID)); assertEquals("0a908a5d-e774-4558-96ff-6edcbba65483", headers.getFirst(Constants.HttpHeaders.ECOMP_REQUEST_ID)); assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID)); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID)); assertEquals("UNKNOWN", headers.getFirst(ONAPLogConstants.Headers.PARTNER_NAME)); } |