Skip to content
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

Replace Intervener with ActiveIntervener and MuteIntervener #3562

Conversation

grobinson-grafana
Copy link
Contributor

This commit replaces the Intervener in timeinterval package with an ActiveIntervener and a MuteIntervener for active time intervals and mute time intervals. It avoids having a double-negative in TimeActiveStage where Mute returns true if its not muted rather than if it is muted, and will also enable us to mark alerts as muted or not within ActiveIntervener and MuteIntervener.

This commit replaces the Intervener in timeinterval package with
an ActiveIntervener and a MuteIntervener for active time intervals
and mute time intervals. It avoids having a double-negative in
TimeActiveStage where Mute returns true if its not muted rather
than if it is muted, and will also enable us to mark alerts as
muted or not within ActiveIntervener and MuteIntervener.

Signed-off-by: George Robinson <[email protected]>
@grobinson-grafana grobinson-grafana force-pushed the grobinson/active-and-mute-intervener branch from fd45cea to e8159a8 Compare October 17, 2023 15:33
Signed-off-by: George Robinson <[email protected]>
intervals map[string][]TimeInterval
}

func (i *ActiveIntervener) Mutes(names []string, now time.Time) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of this - this is pretty much the same logic as the other but with a flipped conditional. I'd rather keep it as is and continue to have the !muted on the stage itself.

This seems like a lot of code to change/add for the sake of a flipping a conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's OK. We'll then need to put the marker back into TimeMuteStage and TimeActiveStage though as otherwise Intervener doesn't know if it's activing or muting.

This seems like a lot of code to change/add for the sake of a flipping a conditional.

Don't forget we'll also be adding the marker, so it won't just be the conditional that changes, but how alerts are marked as muted too.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should introduce it then? It's hard for me to see the benefit of this as is. 😭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do think making time active intervals adhere to the contract of Mute is a good win in of itself. Mute no longer returns false when it should be muted, and true when it shouldn't be muted.

Copy link
Member

Choose a reason for hiding this comment

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

I think my suggestion here would be to keep everything under 1 single interface but add an additional method to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That still doesn't work I'm afraid, because Intervener doesn't know if the intervals in names are active time intervals or mute time intervals.

@grobinson-grafana grobinson-grafana deleted the grobinson/active-and-mute-intervener branch March 1, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants