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

Add metric for GitHub API Rate Limit #5654

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

zxiiro
Copy link
Collaborator

@zxiiro zxiiro commented Sep 12, 2024

This captures the rate limit values from GitHub for the ALI account user/process. We can use this to graph and track how much of the API rate limit is used by the CI infrastructure and flag when we are getting too close to the overall limit.

Closes: pytorch/ci-infra#273

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
torchci ⬜️ Ignored (Inspect) Visit Preview Sep 16, 2024 8:12pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 12, 2024
@zxiiro zxiiro force-pushed the zxiiro/github-ratelimit branch 3 times, most recently from 270d544 to 85c4442 Compare September 12, 2024 16:36
This captures the rate limit values from GitHub for the ALI account
user/process. We can use this to graph and track how much of the API
rate limit is used by the CI infrastructure and flag when we are
getting too close to the overall limit.

Closes: pytorch/ci-infra#273
Signed-off-by: Thanh Ha <[email protected]>
export async function getGitHubRateLimit(installationId: number, metrics: Metrics): Promise<void> {
const ghAuth = await createGithubAuth(installationId, 'installation', Config.Instance.ghesUrlApi, metrics);
const githubInstallationClient = await createOctoClient(ghAuth, Config.Instance.ghesUrl);
const rateLimit = await githubInstallationClient.rateLimit.get();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Calling the RateLimit API does not count towards the rate limit.

It would be more efficient if we can gather this information from an API call that's already happening rather than doing a separate call to the ratelimit API. However I couldn't find where in the code the best place for that would be so I decided on putting in scale-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants