fix: add missing metrics for few gh api callS
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
This commit is contained in:
parent
6cb6350602
commit
d68cc3bf05
4 changed files with 38 additions and 2 deletions
|
|
@ -16,7 +16,6 @@ const metricsGithubSubsystem = "github"
|
|||
|
||||
// RegisterMetrics registers all the metrics
|
||||
func RegisterMetrics() error {
|
||||
|
||||
var collectors []prometheus.Collector
|
||||
collectors = append(collectors,
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue