jihaozh commented on a change in pull request #4599: [TE] Redesign to support
multiple Alert Content formatters
URL: https://github.com/apache/incubator-pinot/pull/4599#discussion_r322499005
##########
File path:
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/alert/v2/AlertTaskRunnerV2.java
##########
@@ -297,23 +297,24 @@ private void sendAnomalyReport() throws Exception {
groupName = sb.toString();
}
// Generate and send out an anomaly report for this group
- EmailContentFormatter emailContentFormatter;
+ EmailContentFormatter emailFormatter;
EmailFormatterConfig emailFormatterConfig =
alertConfig.getEmailFormatterConfig();
+ AlertContentFormatterFactory<BaseNotificationContent>
alertContentFactory = new AlertContentFormatterFactory<>();
+ BaseNotificationContent notificationContent;
try {
- emailContentFormatter =
EmailContentFormatterFactory.fromClassName(emailFormatterConfig.getType());
+ notificationContent =
alertContentFactory.fromClassPath(Class.forName(emailFormatterConfig.getType()).getCanonicalName());
} catch (Exception e) {
LOG.error("User-assigned Email Formatter Config {} is not available.
Use default instead.", alertConfig.getEmailFormatterConfig());
- emailContentFormatter =
EmailContentFormatterFactory.fromClassName(DEFAULT_EMAIL_FORMATTER_TYPE);
+ notificationContent =
alertContentFactory.fromClassPath(Class.forName(DEFAULT_EMAIL_FORMATTER_TYPE).getCanonicalName());
}
- EmailContentFormatterConfiguration emailContemtFormatterConfig =
EmailContentFormatterConfiguration
- .fromThirdEyeAnomalyConfiguration(thirdeyeConfig);
+
+ Properties prop;
if (emailFormatterConfig != null &&
StringUtils.isNotBlank(emailFormatterConfig.getProperties())) {
- emailContentFormatter.init(org.apache.pinot.thirdeye.datalayer.util.
-
StringUtils.decodeCompactedProperties(emailFormatterConfig.getProperties()),
emailContemtFormatterConfig
- );
+ prop =
org.apache.pinot.thirdeye.datalayer.util.StringUtils.decodeCompactedProperties(emailFormatterConfig.getProperties());
Review comment:
can we use shorter package name here?
----------------------------------------------------------------
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]