akshayrai 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_r340338366
##########
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:
The jira description and comment character limits are configurable. These
limits might vary with different projects. So it might be a safer option to not
hard code and truncate in advance.
----------------------------------------------------------------
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]