Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/provider/github/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (

"github.com/google/go-github/v85/github"
providerMetrics "github.com/openshift-pipelines/pipelines-as-code/pkg/provider/providermetrics"
"go.uber.org/zap"
)

const (
// Rate limit warning thresholds.
rateLimitExceeded = 0 // Error when remaining calls are 0
rateLimitCritical = 50 // Warn when remaining calls < 50
rateLimitWarning = 100 // Warn when remaining calls < 100
rateLimitInfo = 500 // Info when remaining calls < 500
Expand Down Expand Up @@ -69,6 +71,13 @@ func (v *Provider) checkRateLimit(resp *github.Response) (remaining string) {
"reset", reset,
}
switch {
case remainingCount == rateLimitExceeded:
v.Logger.Errorw("GitHub API rate limit exceeded", logFields...)
if v.eventEmitter != nil {
v.eventEmitter.EmitMessage(
v.repo, zap.ErrorLevel, "GitHubRateLimitExceeded",
fmt.Sprintf("GitHub API rate limit exceeded, limit: %s, resets at: %s", limit, reset))
}
case remainingCount < rateLimitCritical:
v.Logger.Errorw("GitHub API rate limit critically low", logFields...)
case remainingCount < rateLimitWarning:
Expand Down
Loading