aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java7
3 files changed, 11 insertions, 1 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
index c4e780fa8f..c08952a84d 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
@@ -32,7 +32,8 @@ enum AuditField implements MDCField {
STATUS_CODE(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE),
RESPONSE_CODE(ONAPLogConstants.MDCs.RESPONSE_CODE),
RESPONSE_DESCRIPTION(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION),
- CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS);
+ CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS),
+ INVOCATION_ID(ONAPLogConstants.MDCs.INVOCATION_ID);
private final String key;
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
index f85a6bbe95..54026098c1 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
@@ -17,6 +17,7 @@
package org.openecomp.sdc.logging.slf4j;
import java.text.SimpleDateFormat;
+import java.util.UUID;
import org.openecomp.sdc.logging.api.AuditData;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.MetricsData;
@@ -157,6 +158,7 @@ class SLF4JLoggerWrapper implements Logger {
safePutOnMdc(AuditField.RESPONSE_CODE, audit.getResponseCode());
safePutOnMdc(AuditField.RESPONSE_DESCRIPTION, audit.getResponseDescription());
safePutOnMdc(AuditField.CLIENT_IP_ADDRESS, audit.getClientIpAddress());
+ unsafePutOnMdc(AuditField.INVOCATION_ID, UUID.randomUUID().toString());
if (audit.getStatusCode() != null) {
unsafePutOnMdc(AuditField.STATUS_CODE, audit.getStatusCode().name());
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
index 2b98fc898f..6785c15355 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
@@ -221,6 +221,13 @@ public class SLF4JLoggerWrapperTest {
}
@Test
+ public void auditInvocationIdAvailable() {
+ SpyLogger spy = createSpy();
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build());
+ assertNotNull(spy.mdc().get(AuditField.INVOCATION_ID.asKey()));
+ }
+
+ @Test
public void metricsTargetEntityAvailableWhenPassed() {
final String targetEntity = "MetricsTargetEntity";
SpyLogger spy = createSpy();