|
| 1 | +# Collected and reported metrics |
| 2 | + |
| 3 | +In first place, it is important to differentiate the `workflow_run` |
| 4 | +and the `workflow_job` webhook events. |
| 5 | + |
| 6 | +The `workflow_run` request is triggered when a workflow run is `requested`, |
| 7 | +`in_progress`, `completed` or `failure`. However, for this project, we are not |
| 8 | +interested in the `cancelled` or `skipped` events, so we will ignore them. |
| 9 | + |
| 10 | +On the other hand, the `workflow_job` request is triggered when a |
| 11 | +workflow job is `queued`, `in_progress`, or `completed`. We will also ignore |
| 12 | +the `cancelled` or `skipped` events for `workflow_job` in this project. |
| 13 | + |
| 14 | +## Workflow run |
| 15 | + |
| 16 | +Here are the different metrics collected by the GitHub Actions Exporter |
| 17 | +project for workflow runs: |
| 18 | + |
| 19 | +The number of workflow rebuilds: `github_actions_workflow_rebuild_count`. |
| 20 | + |
| 21 | +The duration of a workflow in seconds: `github_actions_workflow_duration_seconds`. |
| 22 | + |
| 23 | +Count the number of workflows for each state: |
| 24 | + |
| 25 | +- `github_actions_workflow_failure_count` |
| 26 | +- `github_actions_workflow_success_count` |
| 27 | +- `github_actions_workflow_cancelled_count` |
| 28 | +- `github_actions_workflow_inprogress_count` |
| 29 | +- `github_actions_workflow_total_count` |
| 30 | + |
| 31 | +## Workflow job |
| 32 | + |
| 33 | +Here are the different metrics collected by the GitHub Actions |
| 34 | +Exporter project for workflows and jobs. |
| 35 | + |
| 36 | +The duration of a job in seconds: `github_actions_job_duration_seconds`. |
| 37 | + |
| 38 | +Time between when a job is requested and started: `github_actions_job_start_duration_seconds`. |
| 39 | + |
| 40 | +Count the number of jobs for each states: |
| 41 | + |
| 42 | +- `github_actions_job_failure_count` |
| 43 | +- `github_actions_job_success_count` |
| 44 | +- `github_actions_job_cancelled_count` |
| 45 | +- `github_actions_job_inprogress_count` |
| 46 | +- `github_actions_job_queued_count` |
| 47 | +- `github_actions_job_total_count` |
| 48 | + |
| 49 | +## Cost metric |
| 50 | + |
| 51 | +This is the last metric we collect, and it is one of the most important |
| 52 | +ones. It allows us to determine the cost of our CI runs. |
| 53 | + |
| 54 | +### Formula |
| 55 | + |
| 56 | +Here is the formula to calculate the cost over a period of time: |
| 57 | + |
| 58 | +```bash |
| 59 | +cost = duration (per second) / 60 * cost (per minute) |
| 60 | +``` |
| 61 | + |
| 62 | +### How do we find the cost per minute? |
| 63 | + |
| 64 | +#### GitHub |
| 65 | + |
| 66 | +As for GitHub, it is quite simple. They provide us with a fixed value, and |
| 67 | +the price never varies. To give an example, for `ubuntu-latest`, we have a cost |
| 68 | +of 0.008$/min, that's it. Easy! |
| 69 | + |
| 70 | +For larger GitHub hosted runners, such as the high-performance options, the |
| 71 | +pricing structure may differ. The exact details and costs associated with those |
| 72 | +specific runner types can be obtained from |
| 73 | +[GitHub's documentation](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions). |
| 74 | + |
| 75 | +#### Self-Hosted |
| 76 | + |
| 77 | +When it comes to the cost of self-hosted runners, it's a bit more complicated. |
| 78 | + |
| 79 | +To calculate the costs of self-hosted runners, we can play the game of |
| 80 | +calculating for the main ones, namely AWS and Google Cloud Provider (GCP). |
| 81 | + |
| 82 | +The cost can be found based on the machine type in the Management Console |
| 83 | +for AWS (when creating an EC2 instance) and on the |
| 84 | +[Google Cloud website](https://cloud.google.com/compute/vm-instance-pricing) |
| 85 | +for GCP. |
| 86 | + |
| 87 | +Key points to consider for retrieving cost information: |
| 88 | + |
| 89 | +!!! note "Cost for self-hosted runners are approximate" |
| 90 | + |
| 91 | + When retrieving the cost of each key point, |
| 92 | + calculating the exact cost per minute might not be possible |
| 93 | + as it depends on the cloud provider billing policy |
| 94 | + and each individual CI workload: |
| 95 | + |
| 96 | + - Internal cloud provider/lab with dedicated hardware. |
| 97 | + - Cloud provider billing policy for virtual machines is per hour or day only. |
| 98 | + - Price of instance varies during the day, week or month. |
| 99 | + - CI job that uploads a large amount of data. |
| 100 | + |
| 101 | +- RAM and CPU Costs : provided cost per minute for RAM and CPU expenses, can |
| 102 | + be found in the documentation of the respective cloud provider. |
| 103 | +- Storage Costs : provided cost per minute for storage expenses, can |
| 104 | + be found in the documentation of the respective cloud provider. |
| 105 | +- Bandwidth Cost: Directly determining the cost per minute of bandwidth is |
| 106 | + not feasible. |
| 107 | + |
| 108 | +Calculating the bandwidth cost per minutes is up to the discretion of the |
| 109 | +user and will vary depending on the workload. As an example, adding an |
| 110 | +extra 30% is what we found by comparing the values in the documentation |
| 111 | +of different cloud providers (for CPU, RAM, and storage) with the actual |
| 112 | +values available on our invoices. Using this information, |
| 113 | +estimating the overall cost can be done using the following formula: |
| 114 | +(all costs are per minute) |
| 115 | + |
| 116 | +```bash |
| 117 | +cost = (cost_per_flavor + cost_per_storage) * percentage_cost_of_bandwidth |
| 118 | +``` |
| 119 | + |
| 120 | +!!! note |
| 121 | + |
| 122 | + GCP and AWS costs are quite the same for the same flavors. |
| 123 | + |
| 124 | +### The different tags and their associated cost |
| 125 | + |
| 126 | +| Provider | Runner | Cost ($ per min) | |
| 127 | +| -------- | -------------------- | ---------------- | |
| 128 | +| GitHub | `ubuntu-latest` | 0.008 | |
| 129 | +| GitHub | `ubuntu-18.04` | 0.008 | |
| 130 | +| GitHub | `ubuntu-20.04` | 0.008 | |
| 131 | +| GitHub | `ubuntu-22.04` | 0.008 | |
| 132 | +| GitHub | `ubuntu-20.04-4core` | 0.016 | |
| 133 | +| GitHub | `ubuntu-22.04-4core` | 0.016 | |
| 134 | +| GitHub | `ubuntu-22.04-8core` | 0.032 | |
| 135 | +| AWS | `t3.small` | 0.000625 | |
| 136 | +| GCP | `n2-standard-2` | 0.0025 | |
| 137 | +| AWS | `t3.large` | 0.0025 | |
| 138 | +| GCP | `n2-standard-4` | 0.005 | |
| 139 | +| GCP | `n2-standard-8` | 0.01 | |
| 140 | + |
| 141 | +!!! note |
| 142 | + |
| 143 | + Please note that the names of large GitHub hosted runners |
| 144 | + may not be explicitly the same as shown below, but this is |
| 145 | + the naming convention recommended by GitHub. |
0 commit comments