Updated code for metrics logs
Issue-ID: PORTAL-1008
Signed-off-by: Kishore Reddy Dwaram <kishore.reddy.dwaram@att.com>
Change-Id: I10b4bbeba1c4bf119211d41886e52fa44a22ee4f
(cherry picked from commit 6a2eb370ce70dc5f2ee5a401e00b52071ddb0b8e)
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
index b2ef2bc..d45adee 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
@@ -173,13 +173,12 @@
MDC.remove(Configuration.MDC_SERVER_FQDN);
} else {
- MDC.put(SystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
- this.calculateDateTimeDifference(MDC.get(SystemProperties.METRICSLOG_BEGIN_TIMESTAMP),MDC.get(SystemProperties.METRICSLOG_END_TIMESTAMP));
- MDC.put("CustomField1", "INVOKE");
-
+ MDC.put(SystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
+ this.calculateDateTimeDifference(MDC.get(SystemProperties.METRICSLOG_BEGIN_TIMESTAMP),MDC.get(SystemProperties.METRICSLOG_END_TIMESTAMP));
+ MDC.put("CustomField1", "INVOKE");
+ MDC.put("CustomField2", " InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+ logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is started.");
}
- MDC.put("CustomField2", " InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
- logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is started.");
logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName);
} catch (Exception e) {
adviceLogger.error(EELFLoggerDelegate.errorLogger, "before failed", e);
@@ -252,10 +251,9 @@
MDC.put(EPCommonSystemProperties.RESPONSE_CODE, externalAPIResponseCode);
MDC.put(EPCommonSystemProperties.STATUS_CODE, "ERROR");
}
-
+ MDC.put(SystemProperties.STATUS_CODE, "COMPLETE");
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
-
// Log security message, if necessary
if (securityEventType != null) {
MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
@@ -300,15 +298,13 @@
MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
MDC.remove(EPCommonSystemProperties.RESPONSE_CODE);
- } else{
- MDC.put(SystemProperties.CUSTOM_FIELD1, "INVOKE-RETURN");
- }
-
- MDC.put(SystemProperties.STATUS_CODE, "COMPLETE");
+ } else {
+ MDC.put(SystemProperties.CUSTOM_FIELD1, "INVOKE-RETURN");
MDC.put("CustomField2", " InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+ // add the metrics log
+ logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed.");
+ }
logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
- // add the metrics log
- logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed.");
MDC.remove("CustomField1");
MDC.remove("CustomField2");
MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP);