Schedule-based thresholds for array size checks. - #33
Open
lemald wants to merge 20 commits into
Open
Conversation
lemald
marked this pull request as ready for review
August 26, 2026 20:02
lemald
requested review from
a team,
huangh and
npatel-mbta
and removed request for
a team and
huangh
August 26, 2026 20:02
npatel-mbta
approved these changes
Aug 31, 2026
npatel-mbta
left a comment
There was a problem hiding this comment.
I aslo used co-pilot to review the code, and the few minor issues it raised, I reviewed and think they don't really apply.
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.
Asana ticket: 🔮 Build out a way to measure RTR uptime
Note that I used Copilot for the initial implementation, though I read all the code over and modified it in places to be more idiomatic and readable.
To make our alerting and reliability metrics more accurate, we want to be able to dynamically assess our realtime data relative to the level of scheduled service, rather than relative to absolute thresholds. My changes to the README explain the new feature and how to configure it in more detail.
Some notes on how I came up with 0.05 as the multiplier: given that we currently have a shutdown of part of the Orange Line going on, I opted to look at the schedule data there. Grabbing all schedules for route
Orangeand filtering out shuttle bus stop times gave me the following:Meanwhile, querying the
/predictionsendpoint for routeOrangereturned a total of 39 predictions. I wanted to give about a factor of 2 for headroom, and 388 is almost exactly 10 times 39, so 1/10 divided by 2 for the headroom gives a ratio of 0.05. For a non-diversion example I looked at the current situation with light rail: during a representative 2-hour window there were 3000 stop times in the schedule, for a threshold of 150 predictions. In reality, we were producing 1078 predictions, showing that in some situations this is actually a very conservative threshold.