diff options
author | Steve Smokowski <ss835w@att.com> | 2019-07-22 13:17:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-22 13:17:29 +0000 |
commit | bbdb1c45a93194db2712d8c146e263a03737f25c (patch) | |
tree | 8b3069bea4ae84c8e46ecf5a4d42f745a4ec1951 /adapters/mso-openstack-adapters/src | |
parent | 3042cd9564c0d40d6e9296287d6779fa01b9d98b (diff) | |
parent | abe6e93f284c06b999ef1510ea06b14da93117fb (diff) |
Merge "Added servicename to MDC so that it gets logged"
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
5 files changed, 20 insertions, 4 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java index 7500097b6a..8edce124ec 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java @@ -87,9 +87,12 @@ public abstract class AbstractAuditService { } protected void setupMDC(ExternalTask externalTask) { + logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); String msoRequestId = externalTask.getVariable("mso-request-id"); - if (msoRequestId != null && !msoRequestId.isEmpty()) + if (msoRequestId != null && !msoRequestId.isEmpty()) { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); + } + MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName()); } protected long calculateRetryDelay(int currentRetries) { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java index 77229919cd..1e5b6de857 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Optional; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.audit.beans.AuditInventory; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.objects.audit.AAIObjectAuditList; @@ -48,9 +49,9 @@ public class AuditCreateStackService extends AbstractAuditService { public Environment environment; protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { + setupMDC(externalTask); AuditInventory auditInventory = externalTask.getVariable("auditInventory"); Map<String, Object> variables = new HashMap<>(); - setupMDC(externalTask); boolean success = false; try { logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory, @@ -71,6 +72,7 @@ public class AuditCreateStackService extends AbstractAuditService { if (success) { externalTaskService.complete(externalTask, variables); logger.debug("The External Task Id: {} Successful", externalTask.getId()); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { if (externalTask.getRetries() == null) { logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", @@ -80,6 +82,7 @@ public class AuditCreateStackService extends AbstractAuditService { } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) { logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); externalTaskService.complete(externalTask, variables); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(), externalTask.getRetries() - 1, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java index b99eaa98d9..0aa4f9bdc3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Optional; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.audit.beans.AuditInventory; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.objects.audit.AAIObjectAuditList; @@ -52,9 +53,9 @@ public class AuditDeleteStackService extends AbstractAuditService { protected Environment env; protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { + setupMDC(externalTask); AuditInventory auditInventory = externalTask.getVariable("auditInventory"); Map<String, Object> variables = new HashMap<>(); - setupMDC(externalTask); boolean success = false; try { logger.info("Executing External Task Delete Audit Inventory. Retry Number: {}", externalTask.getRetries()); @@ -79,6 +80,7 @@ public class AuditDeleteStackService extends AbstractAuditService { if (success) { externalTaskService.complete(externalTask, variables); logger.debug("The External Task Id: {} Successful", externalTask.getId()); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { if (externalTask.getRetries() == null) { logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", @@ -88,6 +90,7 @@ public class AuditDeleteStackService extends AbstractAuditService { } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) { logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); externalTaskService.complete(externalTask, variables); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(), externalTask.getRetries() - 1, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java index c8ac9d1a58..2ef7d5b325 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Optional; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.audit.beans.AuditInventory; import org.onap.so.objects.audit.AAIObjectAuditList; import org.slf4j.Logger; @@ -24,8 +25,8 @@ public class AuditQueryStackService extends AbstractAuditService { protected AuditDataService auditDataService; protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { - AuditInventory auditInventory = externalTask.getVariable("auditInventory"); setupMDC(externalTask); + AuditInventory auditInventory = externalTask.getVariable("auditInventory"); boolean success = false; Map<String, Object> variables = new HashMap<>(); try { @@ -42,6 +43,7 @@ public class AuditQueryStackService extends AbstractAuditService { if (success) { externalTaskService.complete(externalTask, variables); logger.debug("The External Task {} was Successful", externalTask.getId()); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { if (externalTask.getRetries() == null) { logger.debug("The External Task {} Failed. Setting Retries to Default Start Value: {}", @@ -51,6 +53,7 @@ public class AuditQueryStackService extends AbstractAuditService { } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) { logger.debug("The External Task {} Failed. All Retries Exhausted", externalTask.getId()); externalTaskService.complete(externalTask, variables); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { logger.debug("The External Task {} Failed. Decrementing Retries to {} , Retry Delay: ", externalTask.getId(), externalTask.getRetries() - 1, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java index c106591b25..a6c61704ad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java @@ -77,6 +77,7 @@ public class CreateInventoryTask { if (success) { externalTaskService.complete(externalTask); logger.debug("The External Task Id: {} Successful", externalTask.getId()); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else if (inventoryException) { logger.debug("The External Task Id: {} Failed, Retry not needed", externalTask.getId()); externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE); @@ -89,6 +90,7 @@ public class CreateInventoryTask { } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) { logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE); + logger.info(ONAPLogConstants.Markers.EXIT, "Exiting"); } else { logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(), externalTask.getRetries() - 1, @@ -107,6 +109,8 @@ public class CreateInventoryTask { private void setupMDC(ExternalTask externalTask) { try { + logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); + MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName()); String msoRequestId = externalTask.getVariable("mso-request-id"); if (msoRequestId != null && !msoRequestId.isEmpty()) MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); |