You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/11/04 17:41:04 UTC

[incubator-pinot] branch master updated: [TE][notification] Minor tweeking of jira alerter (#4776)

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 6026746  [TE][notification] Minor tweeking of jira alerter (#4776)
6026746 is described below

commit 602674619d772a0cf9e66a70b0524f588fec6248
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Mon Nov 4 09:40:57 2019 -0800

    [TE][notification] Minor tweeking of jira alerter (#4776)
---
 .../thirdeye/detection/alert/scheme/DetectionJiraAlerter.java |  6 ++++++
 .../thirdeye/notification/commons/ThirdEyeJiraClient.java     | 11 ++++++++++-
 .../notification/formatter/channels/JiraContentFormatter.java |  4 ++--
 3 files changed, 18 insertions(+), 3 deletions(-)

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 93aded6..053f004 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
@@ -72,6 +72,7 @@ public class DetectionJiraAlerter extends DetectionAlertScheme {
   private JiraConfiguration jiraAdminConfig;
 
   public static final String PROP_JIRA_SCHEME = "jiraScheme";
+  public static final int JIRA_DESCRIPTION_MAX_LENGTH = 100000;
 
   public DetectionJiraAlerter(DetectionAlertConfigDTO subsConfig, ThirdEyeAnomalyConfiguration thirdeyeConfig,
       DetectionAlertFilterResult result, ThirdEyeJiraClient jiraClient) {
@@ -97,6 +98,11 @@ public class DetectionJiraAlerter extends DetectionAlertScheme {
     jiraClient.updateIssue(issue, jiraEntity);
 
     try {
+      // Safeguard check from ThirdEye side
+      if (jiraEntity.getDescription().length() > JIRA_DESCRIPTION_MAX_LENGTH) {
+        throw new RuntimeException("Exceeded jira description character limit of {}" + JIRA_DESCRIPTION_MAX_LENGTH);
+      }
+
       jiraClient.addComment(issue, jiraEntity.getDescription());
     } catch (Exception e) {
       // Jira has a upper limit on the number of characters in description. In such cases we will only
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/commons/ThirdEyeJiraClient.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/commons/ThirdEyeJiraClient.java
index 40014f0..63e7cb2 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/commons/ThirdEyeJiraClient.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/commons/ThirdEyeJiraClient.java
@@ -66,16 +66,25 @@ public class ThirdEyeJiraClient {
    */
   public List<Issue> getIssues(String project, List<String> labels, String reporter, long lookBackMillis) {
     List<Issue> issues = new ArrayList<>();
+
     long lookBackDays = TimeUnit.MILLISECONDS.toDays(lookBackMillis);
+    String createdByQuery = "created";
+    if (lookBackDays <= 0) {
+      createdByQuery += "<= -0m";
+    } else {
+      createdByQuery += ">= -" + lookBackDays + "d";
+    }
+
     String andQueryOnLabels = labels.stream()
         .map(label -> "labels = \"" + label + "\"")
         .collect(Collectors.joining(" and "));
 
     StringBuilder jiraQuery = new StringBuilder();
+    // Query by project first as a jira optimization
     jiraQuery.append("project=").append(project);
     jiraQuery.append(" and ").append("reporter IN (").append(reporter).append(")");
     jiraQuery.append(" and ").append(andQueryOnLabels);
-    jiraQuery.append(" and ").append("created>=").append("-").append(lookBackDays).append("d");
+    jiraQuery.append(" and ").append(createdByQuery);
 
     LOG.info("Fetching Jira tickets using query - {}", jiraQuery.toString());
     Iterable<Issue> jiraIssuesIt = restClient.getSearchClient().searchJql(jiraQuery.toString()).claim().getIssues();
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/formatter/channels/JiraContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/formatter/channels/JiraContentFormatter.java
index 61670c5..b33b07e 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/formatter/channels/JiraContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/notification/formatter/channels/JiraContentFormatter.java
@@ -35,7 +35,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.TimeUnit;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.mail.HtmlEmail;
@@ -127,7 +126,8 @@ public class JiraContentFormatter extends AlertContentFormatter {
       jiraEntity.setAssignee(assignee);
     }
 
-    jiraEntity.setMergeGap(MapUtils.getLong(alertClientConfig, PROP_MERGE_GAP, TimeUnit.DAYS.toMillis(1)));
+    // default - report new anomalies by reopening existing jira tickets
+    jiraEntity.setMergeGap(MapUtils.getLong(alertClientConfig, PROP_MERGE_GAP, 0L));
 
     List<String> labels = ConfigUtils.getList(alertClientConfig.get(PROP_LABELS));
     labels.add(PROP_DEFAULT_LABEL);


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