Skip to content

feat(alarm): add support for creating nested composite alarms #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Laxenade
Copy link
Contributor

@Laxenade Laxenade commented May 5, 2025

Fixes #237
Fixes #618
Fixes #640

This commit adds support for creating nested composite alarms (i.e., including composite alarms within another composite alarm when using createCompositeAlarmUsingTag).

To avoid breaking the existing API or changing the current logic for how alarms are looked up during composite alarm creation, the feature is gated behind a flag, which is disabled by default.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@Laxenade Laxenade marked this pull request as ready for review May 5, 2025 03:31
* @param props Customization options for the composite alarm
* @returns Newly created composite alarm
*/
addCompositeAlarmFromAlarmBases(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the new method should also return an AlarmWithAnnotation like addAlarm does for better consistency?

Also not a fan of this method name, but nothing better immediately comes to mind. :\

const alarmBases = [
...alarms.map((alarm) => alarm.alarm),
...compositeAlarms,
] as AlarmBase[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast necessary? I thought CompositeAlarm was already an AlarmBase.

@@ -178,7 +192,7 @@ export class MonitoringFacade extends MonitoringScope {
| IDashboardSegment
| IDynamicDashboardSegment
)[];
protected readonly createdComposites: CompositeAlarm[];
protected readonly createdComposites: CompositeAlarmWithMetadata[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spitballing here, but I wonder if it'd be possible to have a dummy Monitoring segment that just acts as a composite alarm factory that the facade delegates to?

Things like createdAlarms() would "just work" by returning everything, although things like createdCompositeAlarms() would need to filter first. (That said, I wonder if createdAlarms() should return created composite alarms too? It may be more intuitive to do so.)

Not sure how weird it is to have a segment that doesn't actually do any widget things though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants