Skip to content

Commit 2db4cc2

Browse files
committed
Add alert type query with name and description
1 parent 3584b26 commit 2db4cc2

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use models::status::AlertType;
2+
3+
#[derive(Debug, Default)]
4+
pub struct AlertTypesQuery;
5+
6+
/// Describes an alert type with user-facing metadata.
7+
#[derive(Debug, Clone, async_graphql::SimpleObject)]
8+
pub struct AlertTypeInfo {
9+
/// The alert type identifier.
10+
alert_type: AlertType,
11+
/// A short, user-facing title for the alert type.
12+
title: String,
13+
/// A user-facing description of what this alert type means.
14+
description: String,
15+
}
16+
17+
#[async_graphql::Object]
18+
impl AlertTypesQuery {
19+
/// Returns all possible alert types with their user-facing metadata.
20+
async fn alert_types(&self) -> Vec<AlertTypeInfo> {
21+
AlertType::all()
22+
.iter()
23+
.map(|at| AlertTypeInfo {
24+
alert_type: *at,
25+
title: at.title().to_string(),
26+
description: at.description().to_string(),
27+
})
28+
.collect()
29+
}
30+
}

crates/control-plane-api/src/server/public/graphql/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl connection::CursorType for TimestampCursor {
2222
}
2323

2424
mod alert_subscriptions;
25+
mod alert_types;
2526
mod alerts;
2627
mod authorized_prefixes;
2728
mod data_planes;
@@ -50,6 +51,7 @@ pub struct PgDataLoader(pub sqlx::PgPool);
5051
pub struct QueryRoot(
5152
live_spec_refs::LiveSpecsQuery,
5253
alerts::AlertsQuery,
54+
alert_types::AlertTypesQuery,
5355
prefixes::PrefixesQuery,
5456
alert_subscriptions::AlertSubscriptionsQuery,
5557
storage_mappings::StorageMappingsQuery,

crates/models/src/status/alerts.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,65 @@ impl AlertType {
128128
}
129129
}
130130

131+
/// A short, user-facing title for the alert type.
132+
pub fn title(&self) -> &'static str {
133+
match self {
134+
AlertType::AutoDiscoverFailed => "Auto-Discovery Failed",
135+
AlertType::DataMovementStalled => "Data Movement Stalled",
136+
AlertType::FreeTrial => "Free Trial",
137+
AlertType::FreeTrialEnding => "Free Trial Ending",
138+
AlertType::FreeTrialStalled => "Free Trial Stalled",
139+
AlertType::MissingPaymentMethod => "Missing Payment Method",
140+
AlertType::ShardFailed => "Task Failed",
141+
AlertType::TaskChronicallyFailing => "Task Chronically Failing",
142+
AlertType::TaskAutoDisabledFailing => "Task Auto-Disabled (Failing)",
143+
AlertType::TaskIdle => "Task Idle",
144+
AlertType::TaskAutoDisabledIdle => "Task Auto-Disabled (Idle)",
145+
AlertType::BackgroundPublicationFailed => "Background Publication Failed",
146+
}
147+
}
148+
149+
/// A user-facing description of what this alert type means.
150+
pub fn description(&self) -> &'static str {
151+
match self {
152+
AlertType::AutoDiscoverFailed => {
153+
"Triggers when a capture's automated schema discovery fails. The capture may be unable to respond to schema changes in the source system."
154+
}
155+
AlertType::DataMovementStalled => {
156+
"Triggers when a task has not processed any data during its configured alert interval."
157+
}
158+
AlertType::FreeTrial => {
159+
"Triggers when a free trial begins, and resolves when the trial period ends."
160+
}
161+
AlertType::FreeTrialEnding => {
162+
"Triggers when a free trial is getting close to expiring."
163+
}
164+
AlertType::FreeTrialStalled => {
165+
"Triggers when a free trial has expired and no payment method has been added."
166+
}
167+
AlertType::MissingPaymentMethod => {
168+
"Triggers when no payment method is on file, and resolves when one is added."
169+
}
170+
AlertType::ShardFailed => {
171+
"Triggers when a task has experienced repeated failures. It may still make progress, but performance is degraded."
172+
}
173+
AlertType::TaskChronicallyFailing => {
174+
"Triggers when a task has been unable to run for an extended period. It will be automatically disabled unless the issue is addressed."
175+
}
176+
AlertType::TaskAutoDisabledFailing => {
177+
"Triggers when a task is automatically disabled after failing continuously for an extended period."
178+
}
179+
AlertType::TaskIdle => {
180+
"Triggers when a task has not processed any data for an extended period and has not been modified recently. It will be automatically disabled unless a new version is published."
181+
}
182+
AlertType::TaskAutoDisabledIdle => {
183+
"Triggers when a task is automatically disabled after being idle for an extended period without any spec changes."
184+
}
185+
AlertType::BackgroundPublicationFailed => {
186+
"Triggers when an automated background publication fails. Affected tasks are unlikely to function until the issue is addressed."
187+
}
188+
}
189+
}
131190
pub fn from_str(name: &str) -> Option<AlertType> {
132191
for alert_type in AlertType::all() {
133192
if name.eq_ignore_ascii_case(alert_type.name()) {

0 commit comments

Comments
 (0)