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

feat(alerts): check alerts earlier #26843

Merged
merged 5 commits into from
Dec 12, 2024
Merged

Conversation

anirudhpillai
Copy link
Contributor

Problem

Daily/weekly/monthly alert checks were spread out randomly during the day/month to spread out the load on our side. But also meant that we weren't checking/alerting as early as we could.

Changes

Check the daily alerts at start of day, weekly and monthly at start of week/month. But we also account for the team's timezone so these alert checks should still be spread out by the timezone

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

N/A

How did you test this code?

Added tests

@anirudhpillai anirudhpillai requested a review from a team December 11, 2024 15:47
tomorrow_local = datetime.now(team_timezone) + relativedelta(days=1)

# set time to 1:00 AM
one_am_local = tomorrow_local.replace(hour=1, minute=0, second=0, microsecond=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use the minute from the creation date also for daily/weekly/monthly alerts, to further spread out the load (probably won't make too much of a difference).

In the same spirit we could do daily at 1am, weekly at 2am, etc. All of this might be confusing when we communicate the calculation times to users, so we might just keep it as it is as well.

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 a great point. Since we're calculating these during off peak times for the users, might be worth spreading this out :)

@anirudhpillai anirudhpillai merged commit 0c6535e into master Dec 12, 2024
89 checks passed
@anirudhpillai anirudhpillai deleted the feat/alerts-daily-sch branch December 12, 2024 16:52
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