...

Source file src/edge-infra.dev/pkg/f8n/devinfra/github-actions-exporter/metrics/get_billable_from_github.go

Documentation: edge-infra.dev/pkg/f8n/devinfra/github-actions-exporter/metrics

     1  package metrics
     2  
     3  import (
     4  	"context"
     5  	"log"
     6  	"strconv"
     7  
     8  	"github.com/prometheus/client_golang/prometheus"
     9  )
    10  
    11  // getBillableFromGithub - return billable informations for MACOS, WINDOWS and UBUNTU runners.
    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