From 89d9d635ea2e701ae0dce72584b24f1541998787 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Tue, 25 Oct 2022 14:18:21 +0000 Subject: Use the 1.9.4 parent pom in rest-client - work around metrics logging, a proper solution would probably involve updating eelf-core in the logging service Issue-ID: AAI-3564 Signed-off-by: Fiete Ostkamp Change-Id: I8a21089d9b41e9a973c62c9eac22503ad32fa731 --- pom.xml | 7 ++++++- .../org/onap/aai/restclient/client/RestClient.java | 24 +++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 7999b16..4f8b29f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ org.onap.aai.aai-common aai-parent - 1.9.3 + 1.9.4 org.onap.aai @@ -52,6 +52,11 @@ common-logging + + com.att.eelf + eelf-core + + org.mockito mockito-all diff --git a/src/main/java/org/onap/aai/restclient/client/RestClient.java b/src/main/java/org/onap/aai/restclient/client/RestClient.java index 89d5c62..9639c9d 100644 --- a/src/main/java/org/onap/aai/restclient/client/RestClient.java +++ b/src/main/java/org/onap/aai/restclient/client/RestClient.java @@ -31,6 +31,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; + import javax.ws.rs.client.Client; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation.Builder; @@ -39,16 +40,17 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import org.onap.aai.cl.api.LogFields; + import org.onap.aai.cl.api.LogLine; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.cl.mdc.MdcContext; import org.onap.aai.cl.mdc.MdcOverride; import org.onap.aai.restclient.enums.RestAuthenticationMode; import org.onap.aai.restclient.logging.RestClientMsgs; import org.onap.aai.restclient.rest.RestClientBuilder; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** @@ -69,11 +71,10 @@ public class RestClient { private static final String REST_CLIENT_INSTANCE = "REST_CLIENT_INSTANCE"; /** Standard logger for producing log statements. */ - private Logger logger = LoggerFactory.getInstance().getLogger("AAIRESTClient"); + private static EELFLogger logger = EELFManager.getLogger(RestClient.class.getName()); /** Standard logger for producing metric statements. */ - private Logger metricsLogger = LoggerFactory.getInstance().getMetricsLogger("AAIRESTClient"); - + private static EELFLogger metricsLogger = EELFManager.getMetricsLogger(); private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); /** Reusable function call for GET REST operations. */ @@ -389,12 +390,11 @@ public class RestClient { if (responseStatus != null) { responseStatusCodeString = responseStatus.toString(); } - - metricsLogger.info(RestClientMsgs.HTTP_REQUEST_TIME, - new LogFields().setField(LogLine.DefinedFields.STATUS_CODE, responseStatusCodeString) - .setField(LogLine.DefinedFields.RESPONSE_CODE, operationResult.getResultCode()) - .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, operationResult.getResult()), - override, requestType, Long.toString(System.currentTimeMillis() - startTimeInMs), url); + Map logFields = new HashMap(); + logFields.put(LogLine.DefinedFields.STATUS_CODE.name(), responseStatusCodeString); + logFields.put(LogLine.DefinedFields.RESPONSE_CODE.name(), String.valueOf(operationResult.getResultCode())); + logFields.put(LogLine.DefinedFields.RESPONSE_DESCRIPTION.name(), operationResult.getResult()); + metricsLogger.info(RestClientMsgs.HTTP_REQUEST_TIME, logFields.toString(), requestType, Long.toString(System.currentTimeMillis() - startTimeInMs), url); logger.info(RestClientMsgs.HTTP_REQUEST_TIME, requestType, Long.toString(System.currentTimeMillis() - startTimeInMs), url); logger.info(RestClientMsgs.HTTP_RESPONSE, url, -- cgit 1.2.3-korg