feat(metrics): add GitHub API rate limit metrics#138
Draft
aparajon wants to merge 2 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Adds observability for GitHub API usage in SchemaBot by recording per-operation request counts and primary rate-limit headers (limit/remaining/used), and updates GitHub client dependencies to versions that expose the necessary response fields.
Changes:
- Introduce
schemabot.github.requests_totalandschemabot.github.rate_limit.*metrics, including label normalization/allowlisting. - Instrument REST and GraphQL GitHub calls (including auth/token exchange via transport) to emit request and rate-limit metrics.
- Bump
go-githubandghinstallationversions and update affected test imports.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/webhook/webhook_e2e_test.go | Update go-github import to v86 in webhook E2E tests. |
| pkg/webhook/testhelpers_test.go | Update go-github import to v86 in webhook test helpers. |
| pkg/webhook/review_gate_test.go | Update go-github import to v86 in review gate tests. |
| pkg/webhook/review_gate_e2e_test.go | Update go-github import to v86 in review gate E2E tests. |
| pkg/webhook/apply_e2e_test.go | Update go-github import to v86 in apply E2E tests. |
| pkg/webhook/apply_comment_e2e_test.go | Update go-github import to v86 in apply-comment E2E tests. |
| pkg/metrics/README.md | Document new GitHub request + primary rate-limit metrics and recommended dashboards. |
| pkg/metrics/metrics.go | Add GitHub metric constants, normalization/allowlisting, and recorders for new metrics. |
| pkg/metrics/github_metrics_test.go | Add unit tests for GitHub label normalization. |
| pkg/github/reviews.go | Emit GitHub response metrics for reviews/team-members/reviewer-request operations. |
| pkg/github/rate_limit_metrics.go | Add HTTP transport + helpers to record GitHub request + rate-limit headers (incl. GraphQL/auth). |
| pkg/github/rate_limit_metrics_test.go | Add tests validating header-based rate-limit metric recording behavior. |
| pkg/github/pr_info_cache_test.go | Update go-github import to v86 in PR info cache tests. |
| pkg/github/config_test.go | Update go-github import to v86 in GitHub config tests. |
| pkg/github/client.go | Wrap transports/clients to record GitHub metrics; record responses for key REST operations. |
| go.mod | Bump go-github to v86 and ghinstallation to v2.18.0. |
| go.sum | Update sums for bumped dependencies and transitive changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+477
to
+483
| func normalizeGitHubOperation(operation string) string { | ||
| if isKnownGitHubOperation(operation) { | ||
| return operation | ||
| } | ||
| slog.Warn("GitHub metric operation label normalized to unknown", "operation", operation) | ||
| return gitHubMetricValueUnknown | ||
| } |
Comment on lines
+118
to
+123
| if !hasLimit && !hasRemaining { | ||
| return | ||
| } | ||
|
|
||
| used, hasUsed := parseGitHubRateLimitHeader(resp.Header, headerRateLimitUsed) | ||
| if !hasUsed && hasLimit && hasRemaining { |
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.
🤖 Generated by Codex on behalf of @aparajon.
Summary