This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new fdfb97e  [TE][subscription] Dimension Recipient Alerter should be 
agnostic to individual errors; Emit metrics to track emails and jiras (#5091)
fdfb97e is described below

commit fdfb97e3da41149d3605b3931e22e8542704e36c
Author: Akshay Rai <akshayra...@gmail.com>
AuthorDate: Wed Feb 26 08:38:55 2020 -0800

    [TE][subscription] Dimension Recipient Alerter should be agnostic to 
individual errors; Emit metrics to track emails and jiras (#5091)
---
 .../thirdeye/anomaly/utils/ThirdeyeMetricsUtil.java    | 18 ++++++++++++++++++
 .../detection/alert/scheme/DetectionAlertScheme.java   |  5 +++--
 .../detection/alert/scheme/DetectionEmailAlerter.java  |  5 ++++-
 .../detection/alert/scheme/DetectionJiraAlerter.java   | 10 ++++++++--
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/utils/ThirdeyeMetricsUtil.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/utils/ThirdeyeMetricsUtil.java
index 7e40d29..d6de6c2 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/utils/ThirdeyeMetricsUtil.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/utils/ThirdeyeMetricsUtil.java
@@ -173,6 +173,24 @@ public class ThirdeyeMetricsUtil {
   public static final Counter eventScheduledTaskFallbackCounter =
       metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"eventScheduledTaskFallbackCounter");
 
+  public static final Counter emailAlertsSucesssCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"emailAlertsSucesssCounter");
+
+  public static final Counter emailAlertsFailedCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"emailAlertsFailedCounter");
+
+  public static final Counter jiraAlertsSuccessCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"jiraAlertsSuccessCounter");
+
+  public static final Counter jiraAlertsFailedCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"jiraAlertsFailedCounter");
+
+  public static final Counter jiraAlertsNumTicketsCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"jiraAlertsNumTicketsCounter");
+
+  public static final Counter jiraAlertsNumCommentsCounter =
+      metricsRegistry.newCounter(ThirdeyeMetricsUtil.class, 
"jiraAlertsNumCommentsCounter");
+
   public static MetricsRegistry getMetricsRegistry() {
     return metricsRegistry;
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionAlertScheme.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionAlertScheme.java
index 0a4ab18..8aaf6d7 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionAlertScheme.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionAlertScheme.java
@@ -85,12 +85,13 @@ public abstract class DetectionAlertScheme {
    * Fail the alert task if unable to notify owner. However, in case of 
dimensions recipient alerter,
    * do not fail the alert if a subset of recipients are invalid.
    */
-  void handleAlertFailure(int size, IllegalArgumentException e) {
+  void handleAlertFailure(int numOfAnomalies, Exception e) throws Exception {
+    // Dimension recipients not enabled
     if (this.result.getResult().size() == 1) {
       throw e;
     } else {
       LOG.warn("Skipping! Found illegal arguments while sending {} anomalies 
for alert {}." + " Exception message: ",
-          size, this.subsConfig.getId(), e);
+          numOfAnomalies, this.subsConfig.getId(), e);
     }
   }
 }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
index d4e4ab9..24177b2 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
@@ -35,6 +35,7 @@ import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.mail.DefaultAuthenticator;
 import org.apache.commons.mail.EmailException;
 import org.apache.commons.mail.HtmlEmail;
+import org.apache.pinot.thirdeye.anomaly.utils.ThirdeyeMetricsUtil;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.notification.commons.SmtpConfiguration;
 import org.apache.pinot.thirdeye.anomaly.ThirdEyeAnomalyConfiguration;
@@ -218,8 +219,10 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
               new HashSet<>(ConfigUtils.getList(emailRecipients.get(PROP_CC))),
               new 
HashSet<>(ConfigUtils.getList(emailRecipients.get(PROP_BCC))));
           sendEmail(prepareEmailContent(subsConfig, emailClientConfigs, 
anomalyResultListOfGroup, recipients));
+          ThirdeyeMetricsUtil.emailAlertsSucesssCounter.inc();
         }
-      } catch (IllegalArgumentException e) {
+      } catch (Exception e) {
+        ThirdeyeMetricsUtil.emailAlertsFailedCounter.inc();
         super.handleAlertFailure(result.getValue().size(), e);
       }
     }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
index b2b15ba..49f978c 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
@@ -29,6 +29,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 import org.apache.pinot.thirdeye.anomaly.ThirdEyeAnomalyConfiguration;
+import org.apache.pinot.thirdeye.anomaly.utils.ThirdeyeMetricsUtil;
 import org.apache.pinot.thirdeye.anomalydetection.context.AnomalyResult;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
@@ -136,7 +137,7 @@ public class DetectionJiraAlerter extends 
DetectionAlertScheme {
         .getJiraEntity(notification.getDimensionFilters(), 
anomalyResultListOfGroup);
   }
 
-  private void createJiraTickets(DetectionAlertFilterResult results) {
+  private void createJiraTickets(DetectionAlertFilterResult results) throws 
Exception {
     LOG.info("Preparing a jira alert for subscription group id {}", 
this.subsConfig.getId());
     Preconditions.checkNotNull(results.getResult());
     for (Map.Entry<DetectionAlertFilterNotification, 
Set<MergedAnomalyResultDTO>> result : results.getResult().entrySet()) {
@@ -152,13 +153,18 @@ public class DetectionJiraAlerter extends 
DetectionAlertScheme {
         if (!latestJiraIssue.isPresent()) {
           // No existing ticket found. Create a new jira ticket
           String issueKey = jiraClient.createIssue(jiraEntity);
+          ThirdeyeMetricsUtil.jiraAlertsSuccessCounter.inc();
+          ThirdeyeMetricsUtil.jiraAlertsNumTicketsCounter.inc();
           LOG.info("Jira created {}, anomalies reported {}", issueKey, 
result.getValue().size());
         } else {
           // Reopen recent existing ticket and add a comment
           updateJiraAlert(latestJiraIssue.get(), jiraEntity);
+          ThirdeyeMetricsUtil.jiraAlertsSuccessCounter.inc();
+          ThirdeyeMetricsUtil.jiraAlertsNumCommentsCounter.inc();
           LOG.info("Jira updated {}, anomalies reported = {}", 
latestJiraIssue.get().getKey(), result.getValue().size());
         }
-      } catch (IllegalArgumentException e) {
+      } catch (Exception e) {
+        ThirdeyeMetricsUtil.jiraAlertsFailedCounter.inc();
         super.handleAlertFailure(result.getValue().size(), e);
       }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to