alert urgencies

This commit is contained in:
Brandon Thomas committed 2026-03-30 22:15:33 -04:00
1 parent bb9b34648b
commit c3fbbaac88
3 files changed
+40 -15

No files matched your search

+24 -6
View File
@@ -59,7 +59,9 @@ impl PagerBuilder {
RootlyConfigBuilder {
parent: self,
api_key,
alert_urgency_id: None,
urgency_id_high: None,
urgency_id_medium: None,
urgency_id_low: None,
notification_target_type: None,
notification_target_id: None,
}
@@ -130,15 +132,29 @@ impl PagerBuilder {
pub struct RootlyConfigBuilder {
parent: PagerBuilder,
api_key: RootlyApiKey,
alert_urgency_id: Option<String>,
urgency_id_high: Option<String>,
urgency_id_medium: Option<String>,
urgency_id_low: Option<String>,
notification_target_type: Option<String>,
notification_target_id: Option<String>,
}
impl RootlyConfigBuilder {
/// Set the alert urgency ID.
pub fn alert_urgency_id(mut self, id: String) -> Self {
self.alert_urgency_id = Some(id);
/// Set the urgency ID for high-urgency alerts.
pub fn urgency_id_high(mut self, id: String) -> Self {
self.urgency_id_high = Some(id);
self
}
/// Set the urgency ID for medium-urgency alerts.
pub fn urgency_id_medium(mut self, id: String) -> Self {
self.urgency_id_medium = Some(id);
self
}
/// Set the urgency ID for low-urgency alerts.
pub fn urgency_id_low(mut self, id: String) -> Self {
self.urgency_id_low = Some(id);
self
}
@@ -153,7 +169,9 @@ impl RootlyConfigBuilder {
pub fn done(mut self) -> PagerBuilder {
self.parent.client_config = Some(PagerClientConfig::Rootly {
api_key: self.api_key,
alert_urgency_id: self.alert_urgency_id,
urgency_id_high: self.urgency_id_high,
urgency_id_medium: self.urgency_id_medium,
urgency_id_low: self.urgency_id_low,
notification_target_type: self.notification_target_type,
notification_target_id: self.notification_target_id,
});
+12 -4
View File
@@ -38,8 +38,14 @@ pub enum PagerClientConfig {
Rootly {
api_key: RootlyApiKey,
/// Alert urgency ID (e.g. "62fde143-..." maps to "High" in our org).
alert_urgency_id: Option<String>,
/// Alert urgency ID for high-urgency alerts.
urgency_id_high: Option<String>,
/// Alert urgency ID for medium-urgency alerts.
urgency_id_medium: Option<String>,
/// Alert urgency ID for low-urgency alerts.
urgency_id_low: Option<String>,
/// Notification target type (e.g. "User", "EscalationPolicy").
notification_target_type: Option<String>,
@@ -93,7 +99,9 @@ impl PagerClient {
) -> Result<PageSentResult, PagerError> {
let PagerClientConfig::Rootly {
api_key,
alert_urgency_id,
urgency_id_high,
urgency_id_medium: _,
urgency_id_low: _,
notification_target_type,
notification_target_id,
} = &self.client_config else {
@@ -191,7 +199,7 @@ impl PagerClient {
environment_ids: None,
external_id: None,
external_url: None,
alert_urgency_id: alert_urgency_id.clone(),
alert_urgency_id: urgency_id_high.clone(),
notification_target_type: notification_target_type.clone(),
notification_target_id: notification_target_id.clone(),
labels,
@@ -58,11 +58,10 @@ pub fn build_pager(
fn build_rootly_pager(builder: PagerBuilder, api_key: String) -> (Pager, PagerWorker) {
let mut rootly_builder = builder
.rootly(RootlyApiKey::new(api_key));
if let Some(urgency_id) = easyenv::get_env_string_optional("ROOTLY_ALERT_URGENCY_ID") {
rootly_builder = rootly_builder.alert_urgency_id(urgency_id);
}
.rootly(RootlyApiKey::new(api_key))
.urgency_id_high(ROOTLY_URGENCY_ID_HIGH.to_string())
.urgency_id_medium(ROOTLY_URGENCY_ID_MEDIUM.to_string())
.urgency_id_low(ROOTLY_URGENCY_ID_LOW.to_string());
let target_type = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_TYPE");
let target_id = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_ID");