diff options
Diffstat (limited to 'reference/logging-filter/logging-filter-base/src')
2 files changed, 5 insertions, 2 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 23d83fb..79069c1 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 @@ -69,12 +69,15 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders> protected void setupHeaders(Request clientRequest, RequestHeaders requestHeaders) { String requestId = extractRequestID(); + String invocationId = UUID.randomUUID().toString(); addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.TRANSACTION_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId); - addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, partnerName); + logger.info("Setting X-InvocationID header for outgoing request: {}", invocationId); + addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, invocationId); + } protected void setupMDC(Request request) { 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 ed217aa..3729e92 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 @@ -68,7 +68,7 @@ public class MetricLogClientFilterTest { assertEquals("0a908a5d-e774-4558-96ff-6edcbba65483", headers.getFirst(Constants.HttpHeaders.TRANSACTION_ID)); 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)); - assertEquals("8819bfb4-69d2-43fc-b0d6-81d2690533ea", headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID)); + assertNotNull(headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID)); assertEquals("UNKNOWN", headers.getFirst(ONAPLogConstants.Headers.PARTNER_NAME)); } |