Fix to get calling application identifier 69/9369/2
authoranupmarathe <anup.marathe@amdocs.com>
Wed, 30 Aug 2017 09:37:37 +0000 (15:07 +0530)
committeranupmarathe <anup.marathe@amdocs.com>
Wed, 30 Aug 2017 11:21:03 +0000 (16:51 +0530)
As per EELF logging guidelines, component can put a calling application
identifier or user name in MDC against key PartnerName. SO is setting
user name against key PartnerName in LogFilter. By having an identity of
calling application can assist in debugging. To achieve this SO will
check request header key X-FromAppId and set its value against MDC -
FromAppId.

Change-Id: Ib67c5e76fdf5567282200e17210ddb49cf9a57fb
Issue-ID: SO-99
Signed-off-by: anupmarathe <anup.marathe@amdocs.com>
common/src/main/java/org/openecomp/mso/logger/LogFilter.java
common/src/main/java/org/openecomp/mso/logger/MsoLogger.java

index ca25ad2..6eaf356 100644 (file)
@@ -53,6 +53,11 @@ public class LogFilter implements Filter {
                if (null != userPrincipal) {
                        MDC.put (MsoLogger.PARTNERNAME, userPrincipal.getName ());
                }
+               //Set identity of calling application / component
+               String fromAppId = httpRequest.getHeader(MsoLogger.HEADER_FROM_APP_ID);
+               if(fromAppId != null && !fromAppId.isEmpty()) {
+                       MDC.put (MsoLogger.FROM_APP_ID, fromAppId);
+               }
                chain.doFilter(httpRequest, httpResponse);
        }
        
index 4c39815..e9b6fb1 100644 (file)
@@ -71,6 +71,9 @@ public class MsoLogger {
     private static final String USER                        = "User";
     private static final String DUMMY_VALUE                 = "trace-#";
     public static final String  UNKNOWN                     = "UNKNOWN";
+    //For getting an identity of calling application
+    public static final String HEADER_FROM_APP_ID           = "X-FromAppId";
+    public static final String FROM_APP_ID                  = "FromAppId";
     // Audit/Metric log specific
     private static final String BEGINTIME                   = "BeginTimestamp";
     private static final String ENDTIME                     = "EndTimestamp";