diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-10-24 10:29:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-10-24 10:29:06 +0000 |
commit | 32d04d886b60649fe036b335745cbd5fab4898b1 (patch) | |
tree | efb1dc0565e26f332d335cffb071b02f805511d0 /vid-app-common | |
parent | e3817aa5b8600631db0212614c02523716ec08e7 (diff) | |
parent | 55f21cee67b36dd6352a775a50ef048a0ff35140 (diff) |
Merge changes I5c90f5bc,I8883de54
* changes:
fix ApacheClientMetricInterceptor to return expected ResponseCode
don't add request id to MDC in VidLoggerAspect
Diffstat (limited to 'vid-app-common')
3 files changed, 3 insertions, 14 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/ApacheClientMetricInterceptor.java b/vid-app-common/src/main/java/org/onap/vid/logging/ApacheClientMetricInterceptor.java index f5b09501e..51e684456 100644 --- a/vid-app-common/src/main/java/org/onap/vid/logging/ApacheClientMetricInterceptor.java +++ b/vid-app-common/src/main/java/org/onap/vid/logging/ApacheClientMetricInterceptor.java @@ -51,7 +51,7 @@ public abstract class ApacheClientMetricInterceptor extends AbstractMetricLogFil @Override protected String getResponseCode(HttpResponse httpResponse) { - return httpResponse.getStatusLine().getReasonPhrase(); + return String.valueOf(httpResponse.getStatusLine().getStatusCode()); } @Override diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java b/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java index f87297c37..08aaf09ce 100644 --- a/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java +++ b/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java @@ -32,7 +32,6 @@ import org.aspectj.lang.ProceedingJoinPoint; 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; @@ -40,7 +39,6 @@ import org.onap.portalsdk.core.util.SystemProperties; 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; @@ -92,7 +90,7 @@ public class VidLoggerAspect { HttpServletRequest httpServletRequest = httpServletRequestOrNull(joinPoint); fixSetRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequest, joinPoint.getSignature().getDeclaringType().getName()); - addRequestIdToMdcForMetricFilter(httpServletRequest); + fixServerFqdnInMDC(); //Execute the actual method @@ -111,14 +109,6 @@ public class VidLoggerAspect { 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); @@ -166,7 +156,6 @@ public class VidLoggerAspect { String loginId = controllersUtils.extractUserId(httpServletRequest); logger.setRequestBasedDefaultsIntoGlobalLoggingContext(httpServletRequest, appName, requestId, loginId); - } } diff --git a/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java b/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java index 29f17b2e7..43f986501 100644 --- a/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java @@ -67,7 +67,7 @@ public class ApacheClientMetricInterceptorTest { @Test public void testGetResponseCode() { - assertEquals(interceptor.getResponseCode(response), "ok"); + assertEquals(interceptor.getResponseCode(response), "200"); } @Test |