Use head_branch metric (#2549)

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Thang Le
2023-05-28 08:36:55 +01:00
committed by GitHub
parent 90ea691e72
commit e7ec736738
20 changed files with 54 additions and 49 deletions

View File

@@ -10,7 +10,7 @@ import (
"time"
"github.com/go-logr/logr"
gogithub "github.com/google/go-github/v50/github"
gogithub "github.com/google/go-github/v52/github"
"github.com/prometheus/client_golang/prometheus"
"github.com/actions/actions-runner-controller/github"
@@ -98,13 +98,19 @@ func (reader *EventReader) ProcessWorkflowJobEvent(ctx context.Context, event in
labels["organization"] = org
var wn string
var hb string
if e.WorkflowJob != nil {
if n := e.WorkflowJob.WorkflowName; n != nil {
wn = *n
keysAndValues = append(keysAndValues, "workflow_name", *n)
}
if n := e.WorkflowJob.HeadBranch; n != nil {
hb = *n
keysAndValues = append(keysAndValues, "head_branch", *n)
}
}
labels["workflow_name"] = wn
labels["head_branch"] = hb
log := reader.Log.WithValues(keysAndValues...)

View File

@@ -76,7 +76,7 @@ func metricLabels(extras ...string) []string {
}
var (
commonLabels = []string{"runs_on", "job_name", "organization", "repository", "repository_full_name", "owner", "workflow_name"}
commonLabels = []string{"runs_on", "job_name", "organization", "repository", "repository_full_name", "owner", "workflow_name", "head_branch"}
githubWorkflowJobQueueDurationSeconds = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "github_workflow_job_queue_duration_seconds",

View File

@@ -25,7 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/go-logr/logr"
gogithub "github.com/google/go-github/v50/github"
gogithub "github.com/google/go-github/v52/github"
ctrl "sigs.k8s.io/controller-runtime"
"github.com/actions/actions-runner-controller/github"