diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/messageBus/ProcessNotification.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/messageBus/ProcessNotification.java index e33e641f59ce8c0caa222c77574f5376e124e388..21b79cdc0859343dfc512e8d5a87bcd228969226 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/messageBus/ProcessNotification.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/messageBus/ProcessNotification.java @@ -14,7 +14,10 @@ package org.opengroup.osdu.notification.provider.azure.messageBus; +import com.microsoft.applicationinsights.TelemetryClient; +import com.microsoft.applicationinsights.telemetry.RequestTelemetry; import com.microsoft.azure.servicebus.IMessage; +import org.apache.commons.lang3.time.StopWatch; import org.opengroup.osdu.core.common.http.HttpResponse; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.notification.provider.azure.messageBus.thread.ThreadScopeContextHolder; @@ -45,6 +48,10 @@ public class ProcessNotification { private MDCContextMap mdcContextMap; public void performNotification(IMessage message, String subscriptionName) throws Exception { + TelemetryClient telemetryClient = new TelemetryClient(); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + try { NotificationContent notificationContent = requestBodyAdapter.extractNotificationContent(message, subscriptionName); @@ -58,8 +65,22 @@ public class ProcessNotification { HttpResponse response = notificationHandler.notifySubscriber(notificationContent.getNotificationId(), notificationContent.getData(), notificationContent.getExtractAttributes()); + + RequestTelemetry requestTelemetry = new RequestTelemetry( + "SBQueueRequest", + new Date(), + stopWatch.getTime(), + "500", + false); + + requestTelemetry.setId(message.getMessageId()); if (!response.isSuccessCode()) { + telemetryClient.trackRequest(requestTelemetry); throw new Exception(NOT_ACKNOWLEDGE); + }else{ + requestTelemetry.setResponseCode("200"); + requestTelemetry.setSuccess(true); + telemetryClient.trackRequest(requestTelemetry); } } catch (Exception e) { LOGGER.error(String.format("An error occurred performing Notification for message with ID: ", message.getMessageId()), e);