...
1 package metrics
2
3 import (
4 "context"
5 "log"
6 "strconv"
7
8 "github.com/prometheus/client_golang/prometheus"
9 )
10
11
12 func getBillableFromGithub(gauge *prometheus.GaugeVec) {
13 for {
14 for k, v := range workflows[repo] {
15 resp, _, err := client.Actions.GetWorkflowUsageByID(context.Background(), org, repo, k)
16 if err != nil {
17 log.Printf("GetWorkflowUsageByID error for %s: %s", repo, err.Error())
18 } else {
19 gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "MACOS").Set(float64(resp.GetBillable().MacOS.GetTotalMS()) / 1000)
20 gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "WINDOWS").Set(float64(resp.GetBillable().Windows.GetTotalMS()) / 1000)
21 gauge.WithLabelValues(repo, strconv.FormatInt(*v.ID, 10), *v.NodeID, *v.Name, *v.State, "UBUNTU").Set(float64(resp.GetBillable().Ubuntu.GetTotalMS()) / 1000)
22 }
23 }
24 }
25 }
26
View as plain text