package metrics import ( "context" "log" "strconv" "github.com/prometheus/client_golang/prometheus" ) // getBillableFromGithub - return billable informations for MACOS, WINDOWS and UBUNTU runners. func getBillableFromGithub(gauge *prometheus.GaugeVec) { for { for k, v := range workflows[repo] { resp, _, err := client.Actions.GetWorkflowUsageByID(context.Background(), org, repo, k) if err != nil { log.Printf("GetWorkflowUsageByID error for %s: %s", repo, err.Error()) } else { gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "MACOS").Set(float64(resp.GetBillable().MacOS.GetTotalMS()) / 1000) gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "WINDOWS").Set(float64(resp.GetBillable().Windows.GetTotalMS()) / 1000) gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "UBUNTU").Set(float64(resp.GetBillable().Ubuntu.GetTotalMS()) / 1000) } } } }