github-readme-stats
github-readme-stats copied to clipboard
feat: add PAT monitoring functions
This commit adds two monitoring functions that can be used to check whether the PATs are functioning correctly:
- status/up: Returns whether the PATs are rate limited.
- status/pat-info: Returns information about the PATs.
@anuraghazra I created this PR for you to review the two PAT monitoring functions I added to the https://github.com/anuraghazra/github-readme-stats/tree/monitoring branch. We can, however, keep these cloud functions on the monitoring branch since they are not meant to be used by the users.
The up
function is meant to be run in dashboard software like Grafana to see how many times in a given day the PATs were limited. The pat-info
function can check if PATs are expired. I added caching headers to these functions to prevent abuse (i.e. 1 req per 10 min).
See in action
Up: https://github-readme-stats-git-monitoring-github-readme-stats-team.vercel.app/api/status/up. PAT-info: https://github-readme-stats-git-monitoring-github-readme-stats-team.vercel.app/api/status/pat-info.
Dynamic badge
When you supply the type=shields
argument to the Up function, it will return a dynamic shields.io JSON object. This object can be used to generate a shields.io badge that shows whether the Public Vercel instance is rate limited. We can change the badge label and message to our liking. You can also retrieve the result as a JSON object using the type=json
argument.
Result
Not sure if the pa-info
function is working correctly. It worked locally and for my own instance (see https://github-readme-stats-git-monitoring-rickstaa.vercel.app/api/status/pat-info), but for the public instance, it looks like we only have one valid PAT. I think the function puts rate_limited
PATs in the expired field. I couldn't find information about the exact behaviour (i.e. error thrown) when a PAT token is limited since I didn't have a rate-limited token.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated |
---|---|---|---|---|
github-readme-stats | ✅ Ready (Inspect) | Visit Preview | 💬 Add your feedback | Jan 28, 2023 at 2:20PM (UTC) |
Codecov Report
Base: 96.91% // Head: 97.24% // Increases project coverage by +0.32%
:tada:
Coverage data is based on head (
b79cc44
) compared to base (99d9d3c
). Patch coverage: 96.77% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #2178 +/- ##
==========================================
+ Coverage 96.91% 97.24% +0.32%
==========================================
Files 22 24 +2
Lines 3896 4144 +248
Branches 337 379 +42
==========================================
+ Hits 3776 4030 +254
+ Misses 118 112 -6
Partials 2 2
Impacted Files | Coverage Δ | |
---|---|---|
api/status/up.js | 95.14% <95.14%> (ø) |
|
api/status/pat-info.js | 97.70% <97.70%> (ø) |
|
src/common/utils.js | 100.00% <100.00%> (ø) |
|
src/common/retryer.js | 96.87% <0.00%> (+21.87%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Any particular reason for not merging? This seems pretty useful to me for monitoring uptime.
Edit: Your domain works well, but wouldn't it be better if all features were included in master
?
Any particular reason for not merging? This seems pretty useful to me for monitoring uptime.
Edit: Your domain works well, but wouldn't it be better if all features were included in
master
?
There is no reason other than this being an OS project and I want to give @anuraghazra all the time he needs to review it before we merge it. 👍
Any particular reason for not merging? This seems pretty useful to me for monitoring uptime. Edit: Your domain works well, but wouldn't it be better if all features were included in
master
?There is no reason other than this being an OS project and I want to give @anuraghazra all the time he needs to review it before we merge it. +1
Right. There's a small chance @anuraghazra might have forgotten about this though, since the last comment was on Oct 2022 😅
Yeah I forgot, I did the review and made few changes.
I'll take a final look today and merge it.
Tests are failing can you check?
Tests are failing can you check?
Of course! Your new code stringifies the response where my tests expected a JS object. Fixed 👍🏻.
shield badge is failing 🤔
shield badge is failing thinking
I quickly checked why the shields were not working. It looks like that although the PR works locally, Vercel gives a 403 error:
- Local endpoint: http://localhost:3000/api/status/up?type=shields
- Remote endpoint: https://github-readme-stats-git-monitoring-github-readme-stats-team.vercel.app/api/status/up?type=shields
I use https://shields.io/endpoint for the badge. I am not a member of the Vercel GRS team, so I can not see what goes wrong. 😅