Fix sample rate calculator estimated traffic overshoot when date range is longer than site stats range#6506
Open
apata wants to merge 3 commits into
Open
Fix sample rate calculator estimated traffic overshoot when date range is longer than site stats range#6506apata wants to merge 3 commits into
apata wants to merge 3 commits into
Conversation
70b997a to
b26fdb5
Compare
…e is longer than site stats range
965701f to
4416b67
Compare
… than 30 days of stats
Contributor
Author
|
There's one more buggy scenario that I noticed: when the end date is far in the future, we'll overestimate events to scan and use an inappropriate sample rate. A query from the year 2026 to the year 2100 would estimate events to scan to be ~75 years worth of last 30 month average event count, while the actual events to scan would be half a year's worth, up to now. Can't have events in the future. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This PR fixes how we estimate traffic to calculate the sample rate for the query.
There were two issues. The first was noticed by a user, the second by me when I was fixing the first.
1) Overestimating events to scan for longer queries
We were overestimating the events the query would scan when the query start date was significantly before site stats start date, e.g. date range is 1970 to 2026, but stats actually start on 2025.
Previously, the calculator when run for this query would have estimated traffic to be 56 years worth of last month's average daily traffic.
Now, the calculator takes into account that stats start from 2025, so for this query, the estimated traffic is 1 years worth of last month's average daily traffic.
2) Underestimating events to scan for newer sites with high ingestion rate
We were underestimating the events the query would scan when the site's ingest counters have accumulated over less than 30 days.
Previously, a query for a new site ingesting 10M events per day for 3 days would not have been sampled, but a query for an older site ingesting 10M events per day for the last 30 days would have been. Expected is that both are sampled with the same rate.
Tests
Changelog
Documentation
Dark mode