feat(alerting): core enums + AlertScope
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum AggregationOp { MAX, MIN, AVG, LATEST }
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public record AlertScope(String appSlug, String routeId, String agentId) {
|
||||
public boolean isEnvWide() { return appSlug == null && routeId == null && agentId == null; }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum AlertSeverity { CRITICAL, WARNING, INFO }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum AlertState { PENDING, FIRING, ACKNOWLEDGED, RESOLVED }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum Comparator { GT, GTE, LT, LTE, EQ }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum ConditionKind { ROUTE_METRIC, EXCHANGE_MATCH, AGENT_STATE, DEPLOYMENT_STATE, LOG_PATTERN, JVM_METRIC }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum FireMode { PER_EXCHANGE, COUNT_IN_WINDOW }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum NotificationStatus { PENDING, DELIVERED, FAILED }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum RouteMetric { ERROR_RATE, P95_LATENCY_MS, P99_LATENCY_MS, THROUGHPUT, ERROR_COUNT }
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
public enum TargetKind { USER, GROUP, ROLE }
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.cameleer.server.core.alerting;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AlertScopeTest {
|
||||
|
||||
@Test
|
||||
void allFieldsNullIsEnvWide() {
|
||||
var s = new AlertScope(null, null, null);
|
||||
assertThat(s.isEnvWide()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void appScoped() {
|
||||
var s = new AlertScope("orders", null, null);
|
||||
assertThat(s.isEnvWide()).isFalse();
|
||||
assertThat(s.appSlug()).isEqualTo("orders");
|
||||
}
|
||||
|
||||
@Test
|
||||
void enumsHaveExpectedValues() {
|
||||
assertThat(AlertSeverity.values()).containsExactly(
|
||||
AlertSeverity.CRITICAL, AlertSeverity.WARNING, AlertSeverity.INFO);
|
||||
assertThat(AlertState.values()).containsExactly(
|
||||
AlertState.PENDING, AlertState.FIRING, AlertState.ACKNOWLEDGED, AlertState.RESOLVED);
|
||||
assertThat(ConditionKind.values()).hasSize(6);
|
||||
assertThat(TargetKind.values()).containsExactly(
|
||||
TargetKind.USER, TargetKind.GROUP, TargetKind.ROLE);
|
||||
assertThat(NotificationStatus.values()).containsExactly(
|
||||
NotificationStatus.PENDING, NotificationStatus.DELIVERED, NotificationStatus.FAILED);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user