diff --git a/metrics/metrics.go b/metrics/metrics.go index 62bdf2c2..44b75031 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -16,7 +16,6 @@ const metricsGithubSubsystem = "github" // RegisterMetrics registers all the metrics func RegisterMetrics() error { - var collectors []prometheus.Collector collectors = append(collectors, diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index cf318c65..e71f04d4 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -306,7 +306,19 @@ func (r *enterprise) FetchDbInstances() ([]params.Instance, error) { } func (r *enterprise) RemoveGithubRunner(runnerID int64) (*github.Response, error) { - return r.ghcEnterpriseCli.RemoveRunner(r.ctx, r.cfg.Name, runnerID) + metrics.GithubOperationCount.WithLabelValues( + "RemoveRunner", // label: operation + metricsLabelEnterpriseScope, // label: scope + ).Inc() + ghResp, err := r.ghcEnterpriseCli.RemoveRunner(r.ctx, r.cfg.Name, runnerID) + if err != nil { + metrics.GithubOperationFailedCount.WithLabelValues( + "RemoveRunner", // label: operation + metricsLabelEnterpriseScope, // label: scope + ).Inc() + return nil, err + } + return ghResp, nil } func (r *enterprise) ListPools() ([]params.Pool, error) { diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 3de5a9b1..0eee23f4 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -352,9 +352,17 @@ func (r *organization) JwtToken() string { } func (r *organization) GetGithubRegistrationToken() (string, error) { + metrics.GithubOperationCount.WithLabelValues( + "CreateOrganizationRegistrationToken", // label: operation + metricsLabelOrganizationScope, // label: scope + ).Inc() tk, ghResp, err := r.ghcli.CreateOrganizationRegistrationToken(r.ctx, r.cfg.Name) if err != nil { + metrics.GithubOperationFailedCount.WithLabelValues( + "CreateOrganizationRegistrationToken", // label: operation + metricsLabelOrganizationScope, // label: scope + ).Inc() if ghResp != nil && ghResp.StatusCode == http.StatusUnauthorized { return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching token") } diff --git a/runner/pool/repository.go b/runner/pool/repository.go index c21e49a0..9ba77c13 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -100,8 +100,16 @@ func (r *repository) GetJITConfig(ctx context.Context, instance string, pool par // TODO(gabriel-samfira): Should we make this configurable? WorkFolder: github.String("_work"), } + metrics.GithubOperationCount.WithLabelValues( + "GenerateRepoJITConfig", // label: operation + metricsLabelRepositoryScope, // label: scope + ).Inc() jitConfig, resp, err := r.ghcli.GenerateRepoJITConfig(ctx, r.cfg.Owner, r.cfg.Name, &req) if err != nil { + metrics.GithubOperationFailedCount.WithLabelValues( + "GenerateRepoJITConfig", // label: operation + metricsLabelRepositoryScope, // label: scope + ).Inc() if resp != nil && resp.StatusCode == http.StatusUnauthorized { return nil, nil, fmt.Errorf("failed to get JIT config: %w", err) } @@ -395,8 +403,17 @@ func (r *repository) InstallHook(ctx context.Context, req *github.Hook) (params. return params.HookInfo{}, errors.Wrap(err, "validating hook request") } + metrics.GithubOperationCount.WithLabelValues( + "CreateRepoHook", // label: operation + metricsLabelRepositoryScope, // label: scope + ).Inc() + hook, _, err := r.ghcli.CreateRepoHook(ctx, r.cfg.Owner, r.cfg.Name, req) if err != nil { + metrics.GithubOperationFailedCount.WithLabelValues( + "CreateRepoHook", // label: operation + metricsLabelRepositoryScope, // label: scope + ).Inc() return params.HookInfo{}, errors.Wrap(err, "creating repository hook") }