From 057c89a2d1db077fa2238c02f998e4dbe9c47268 Mon Sep 17 00:00:00 2001 From: vidhyasree Date: Thu, 21 Jun 2018 16:33:20 -0400 Subject: Shore up Logging Score on DGs Modify TopologyService and DG calls to have all logging fields Issue-ID: APPC-1020 Change-Id: I60078960ed0cfa8c70d0f4673c6d4a5026afc673 Signed-off-by: vidhyasree --- .../main/java/org/onap/appc/executor/impl/CommandTask.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-core') diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/onap/appc/executor/impl/CommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/onap/appc/executor/impl/CommandTask.java index 0784ffcbe..965664429 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/onap/appc/executor/impl/CommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/onap/appc/executor/impl/CommandTask.java @@ -45,6 +45,7 @@ import org.osgi.framework.ServiceReference; import org.slf4j.MDC; import java.net.InetAddress; +import java.util.UUID; import static com.att.eelf.configuration.Configuration.*; import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; @@ -169,7 +170,17 @@ public class CommandTask implements Runnable { private void setInitialLogProperties(CommandRequest request) { - MDC.put(MDC_KEY_REQUEST_ID, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getRequestId()); + String reqId = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getRequestId(); + + try { + MDC.put(MDC_KEY_REQUEST_ID, UUID.fromString(reqId).toString()); + //reaching here without exception means existing RequestId is + //valid UUID as per ECOMP logging standards + } catch (Exception e) { + String reqIdUUID = UUID.randomUUID().toString(); + MDC.put(MDC_KEY_REQUEST_ID, reqIdUUID); + logger.info("Replaced invalid requestID of " + reqId + ". New value is " + reqIdUUID + "."); + } if (request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId() != null) MDC.put(MDC_SERVICE_INSTANCE_ID, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getActionIdentifiers().getServiceInstanceId()); MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getOriginatorId()); -- cgit 1.2.3-korg