import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.portalsdk.core.logging.aspect.EELFLoggerAdvice;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.service.AppService;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.onap.vid.controller.ControllersUtils;
import org.onap.vid.utils.SystemPropertiesWrapper;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(),joinPoint.getSignature().getName()};
Object[] returnArgs = advice.before(securityEventType, fabricateArgsWithNull(), passOnArgs);
- fixSetRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequestOrNull(joinPoint),
+ HttpServletRequest httpServletRequest = httpServletRequestOrNull(joinPoint);
+ fixSetRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequest,
joinPoint.getSignature().getDeclaringType().getName());
-
+ addRequestIdToMdcForMetricFilter(httpServletRequest);
fixServerFqdnInMDC();
//Execute the actual method
return result;
}
+ //prepare MDC for org.onap.logging.filter.base.AbstractMetricLogFilter
+ private void addRequestIdToMdcForMetricFilter(HttpServletRequest httpServletRequest) {
+ if (httpServletRequest!=null) {
+ String requestId = UserUtils.getRequestId(httpServletRequest);
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ }
+ }
+
// Set the status code into MDC *before* the metrics log is written by advice.after()
private void fixStatusCodeInMDC(String restStatus) {
EELFLoggerDelegate.mdcPut(SystemProperties.STATUS_CODE, restStatus);
String loginId = controllersUtils.extractUserId(httpServletRequest);
logger.setRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequest, appName, requestId, loginId);
+
}
}