MCPcopy Create free account
hub / github.com/cloudbase/garm / recordLimits

Method recordLimits

util/github/client.go:580–607  ·  view source on GitHub ↗
(core github.Rate)

Source from the content-addressed store, hash-verified

578}
579
580func (g *githubClient) recordLimits(core github.Rate) {
581 limit := params.GithubRateLimit{
582 Limit: core.Limit,
583 Used: core.Used,
584 Remaining: core.Remaining,
585 Reset: core.Reset.Unix(),
586 }
587 cache.SetCredentialsRateLimit(g.entity.Credentials.ID, limit)
588
589 // Record Prometheus metrics
590 credID := fmt.Sprintf("%d", g.entity.Credentials.ID)
591 credName := g.entity.Credentials.Name
592 endpoint := g.entity.Credentials.Endpoint.Name
593 if endpoint == "" {
594 endpoint = g.entity.Credentials.BaseURL
595 }
596
597 labels := map[string]string{
598 "credential_name": credName,
599 "credential_id": credID,
600 "endpoint": endpoint,
601 }
602
603 metrics.GithubRateLimitLimit.With(labels).Set(float64(core.Limit))
604 metrics.GithubRateLimitRemaining.With(labels).Set(float64(core.Remaining))
605 metrics.GithubRateLimitUsed.With(labels).Set(float64(core.Used))
606 metrics.GithubRateLimitResetTimestamp.With(labels).Set(float64(core.Reset.Unix()))
607}
608
609func NewRateLimitClient(ctx context.Context, credentials params.ForgeCredentials) (common.RateLimitClient, error) {
610 httpClient, err := credentials.GetHTTPClient(ctx)

Callers 13

ListEntityHooksMethod · 0.95
GetEntityHookMethod · 0.95
DeleteEntityHookMethod · 0.95
PingEntityHookMethod · 0.95
ListEntityRunnersMethod · 0.95
RemoveEntityRunnerMethod · 0.95
GetEntityJITConfigMethod · 0.95

Calls 2

SetCredentialsRateLimitFunction · 0.92
SetMethod · 0.45

Tested by

no test coverage detected