@SuppressWarnings("unchecked") public static void alertException( String pipelineName, String revision, MetricRegistry metrics, Object value, RuleDefinition ruleDefinition) { final Map<String, Object> alertResponse = new HashMap<>(); alertResponse.put(EmailConstants.EXCEPTION_MESSAGE, value); Gauge<Object> gauge = MetricsConfigurator.getGauge(metrics, AlertsUtil.getAlertGaugeName(ruleDefinition.getId())); if (gauge != null) { // remove existing gauge MetricsConfigurator.removeGauge( metrics, AlertsUtil.getAlertGaugeName(ruleDefinition.getId()), pipelineName, revision); } Gauge<Object> alertResponseGauge = new Gauge<Object>() { @Override public Object getValue() { return alertResponse; } }; MetricsConfigurator.createGauge( metrics, AlertsUtil.getAlertGaugeName(ruleDefinition.getId()), alertResponseGauge, pipelineName, revision); }
public static Gauge<Object> createAlertResponseGauge( String pipelineName, String revision, MetricRegistry metrics, Object value, RuleDefinition ruleDefinition) { final Map<String, Object> alertResponse = new HashMap<>(); alertResponse.put(EmailConstants.CURRENT_VALUE, value); Gauge<Object> alertResponseGauge = new Gauge<Object>() { @Override public Object getValue() { return alertResponse; } }; alertResponse.put(EmailConstants.TIMESTAMP, System.currentTimeMillis()); List<String> alertTexts = new ArrayList<>(); alertTexts.add(ruleDefinition.getAlertText()); alertResponse.put(EmailConstants.ALERT_TEXTS, alertTexts); MetricsConfigurator.createGauge( metrics, AlertsUtil.getAlertGaugeName(ruleDefinition.getId()), alertResponseGauge, pipelineName, revision); return alertResponseGauge; }