xiaohui-sun commented on a change in pull request #4748: [TE][notification] 
Ability to reopen and reuse existing Jira tickets for alerts
URL: https://github.com/apache/incubator-pinot/pull/4748#discussion_r340300961
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
 ##########
 @@ -76,43 +78,81 @@ public DetectionJiraAlerter(ADContentFormatterContext 
adContext, ThirdEyeAnomaly
     super(adContext, result);
     this.teConfig = thirdeyeConfig;
 
-    init();
+    this.jiraAdminConfig = 
JiraConfiguration.createFromProperties(this.teConfig.getAlerterConfiguration().get(JIRA_CONFIG_KEY));
+    this.jiraClient = new ThirdEyeJiraClient(this.jiraAdminConfig);
   }
 
-  private void init() {
-    this.jiraAdminConfig = 
JiraConfiguration.createFromProperties(this.teConfig.getAlerterConfiguration().get(JIRA_CONFIG_KEY));
-    this.jiraRestClient = new 
AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(
-        URI.create(jiraAdminConfig.getJiraHost()),
-        jiraAdminConfig.getJiraUser(),
-        jiraAdminConfig.getJiraPassword());
+  private void updateJiraAlert(Issue issue, JiraEntity jiraEntity) {
+    // Append labels
+    jiraEntity.getLabels().addAll(issue.getLabels());
+    
jiraEntity.setLabels(jiraEntity.getLabels().stream().distinct().collect(Collectors.toList()));
+
+    jiraClient.reopenIssue(issue);
+    jiraClient.updateIssue(issue, jiraEntity);
+
+    try {
+      jiraClient.addComment(issue, jiraEntity.getDescription());
+    } catch (Exception e) {
+      // Jira has a upper limit on the number of characters. In such cases we 
will only share a link in the comment.
 
 Review comment:
   It looks weird that this is handled in exception handling.
   Can we do the truncation in ahead?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to