Skip to content

Commit

Permalink
Refactor isAnomalyDetectionOperator method
Browse files Browse the repository at this point in the history
  • Loading branch information
scorbiere committed Aug 29, 2024
1 parent a0fe2b0 commit 8179b2d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/aws-cdk-lib/aws-cloudwatch/lib/alarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ const OPERATOR_SYMBOLS: { [key: string]: string } = {
LessThanOrEqualToThreshold: '<=',
};

const ANOMALY_DETECTION_OPERATORS: ComparisonOperator[] = [
ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD,
ComparisonOperator.GREATER_THAN_UPPER_THRESHOLD,
ComparisonOperator.LESS_THAN_LOWER_THRESHOLD,
];
/**
* Specify how missing data points are treated during alarm evaluation
*/
Expand Down Expand Up @@ -151,9 +156,7 @@ export class Alarm extends AlarmBase {
* @returns true if the operator is an anomaly detection operator, false otherwise.
*/
public static isAnomalyDetectionOperator(operator: ComparisonOperator): boolean {
return operator === ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD
|| operator === ComparisonOperator.GREATER_THAN_UPPER_THRESHOLD
|| operator === ComparisonOperator.LESS_THAN_LOWER_THRESHOLD;
return ANOMALY_DETECTION_OPERATORS.includes(operator);
}

/**
Expand Down

0 comments on commit 8179b2d

Please sign in to comment.