-
Notifications
You must be signed in to change notification settings - Fork 54
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: Add grace period to uptime check #167
Conversation
function groupUptimeChecksByPeriod(uptimeChecks: { isOnline: boolean; checkDate: string }[] = []) { | ||
const groupedSnapshots: { checkDate: Date; checks: boolean[] }[] = []; | ||
|
||
uptimeChecks.toSorted((a, b) => new Date(a.checkDate).getTime() - new Date(b.checkDate).getTime()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I changed the sort
for toSorted
to make use of the new immutable array methods which I prefer, but forgot to add the new variable. 😄 There's some other cool ones like toSpliced
and toReversed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, I like that too!
const uptime1d = provider.total1d > 0 ? provider.online1d / provider.total1d : 0; | ||
const uptime7d = provider.total7d > 0 ? provider.online7d / provider.total7d : 0; | ||
const uptime30d = provider.total30d > 0 ? provider.online30d / provider.total30d : 0; | ||
const uptime1d = Math.max(0, 1 - offline_seconds_1d / (24 * 60 * 60)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't mind this numbers. just dropping it here https://www.npmjs.com/package/time-constants - used to use it. a lib is quite simple but improves readability quite a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I found out that date-fns
has similar constants so I used those instead. Way more readable 👍
})); | ||
} | ||
|
||
const uptimePeriods = groupUptimeChecksByPeriod(provider?.uptime || []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method could be extracted as a hook with useMemo
since it's called on every render and does a decent amount of calculations.
ac7c09d
to
eafb3ec
Compare
eafb3ec
to
2758a90
Compare
Improvements to the provider uptime tracking system #152
Added a grace period before treating a provider as completely offline. This will reflect in the following places:
/internal/gpu-prices
endpoint used by the GPU Pricing page/internal/gpu
&/internal/provider-versions
endpoints used for internal trackingThe default grace period is 3h, but this can be changed with the
ProviderUptimeGracePeriodMinutes
env var in the api.When a provider fails an uptime check, start retrying every minutes and slowly increase the interval based on the following table: