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

WaitStage for Grafana Alertmanager #278

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

Conversation

yuri-tceretian
Copy link
Contributor

This PR introduces a new implementation of WaitStage that has two differences from the default one:

  • more effective timer. Instead of using time.After that leaks if the context is stopped (for example when the configuration is updated), it uses time.Timer with proper finalization
  • log message in the case when the pipeline is resumed. This should give us a better picture of the pipeline timeline while investigating in HA mode.

@yuri-tceretian yuri-tceretian requested a review from a team as a code owner February 7, 2025 18:36
@yuri-tceretian yuri-tceretian force-pushed the yuri-tceretian/wait-stage branch from a704c1a to 20a5381 Compare February 7, 2025 18:38
notify/stages/wait_stage.go Show resolved Hide resolved
Comment on lines +43 to +44
t := time.NewTimer(wait)
defer t.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't know about this, good catch. It seems like this was fixed in 1.23 though. As per the time.After docs:

Before Go 1.23, this documentation warned that the underlying Timer would not be recovered by the garbage collector until the timer fired, and that if efficiency was a concern, code should use NewTimer instead and call Timer.Stop if the timer is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced, unstopped timers. There is no reason to prefer NewTimer when After will do.

Considering Grafana is already in 1.23, we could consider updating alerting and get this for free. We could keep this for the logs in any case - wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch :) can change it back then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants