From 2b9ac4cf163a3fc78c9f23551f57841a6c447ef2 Mon Sep 17 00:00:00 2001 From: Alberto Llamas Date: Sat, 17 Sep 2022 15:09:49 +0200 Subject: [PATCH] Fix: Error when enabling prometheus metrics (#2379) Prometheus metrics names have some restrictions that must match the regex `[a-zA-Z_:][a-zA-Z0-9_:]*` --- server/controllers/events/events_controller.go | 6 +++--- server/events/instrumented_pull_closed_executor.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/controllers/events/events_controller.go b/server/controllers/events/events_controller.go index f2697edff9..e6946b9f17 100644 --- a/server/controllers/events/events_controller.go +++ b/server/controllers/events/events_controller.go @@ -158,7 +158,7 @@ func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Re githubReqID := "X-Github-Delivery=" + r.Header.Get("X-Github-Delivery") logger := e.Logger.With("gh-request-id", githubReqID) - scope := e.Scope.SubScope("github.event") + scope := e.Scope.SubScope("github_event") logger.Debug("request valid") @@ -169,10 +169,10 @@ func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Re switch event := event.(type) { case *github.IssueCommentEvent: resp = e.HandleGithubCommentEvent(event, githubReqID, logger) - scope = scope.SubScope(fmt.Sprintf("comment.%s", *event.Action)) + scope = scope.SubScope(fmt.Sprintf("comment_%s", *event.Action)) case *github.PullRequestEvent: resp = e.HandleGithubPullRequestEvent(logger, event, githubReqID) - scope = scope.SubScope(fmt.Sprintf("pr.%s", *event.Action)) + scope = scope.SubScope(fmt.Sprintf("pr_%s", *event.Action)) default: resp = HTTPResponse{ body: fmt.Sprintf("Ignoring unsupported event %s", githubReqID), diff --git a/server/events/instrumented_pull_closed_executor.go b/server/events/instrumented_pull_closed_executor.go index 87fd73bbfc..6daa7c559f 100644 --- a/server/events/instrumented_pull_closed_executor.go +++ b/server/events/instrumented_pull_closed_executor.go @@ -20,7 +20,7 @@ func NewInstrumentedPullClosedExecutor( ) PullCleaner { return &InstrumentedPullClosedExecutor{ - scope: scope.SubScope("pullclosed.cleanup"), + scope: scope.SubScope("pullclosed_cleanup"), log: log, cleaner: cleaner, }