- Notifications
You must be signed in to change notification settings - Fork1k
Commit0ab345c
authored
feat: add prebuild timing metrics to Prometheus (#19503)
## DescriptionThis PR introduces one counter and two histograms related to workspacecreation and claiming. The goal is to provide clearer observability intohow workspaces are created (regular vs prebuild) and the time cost ofthose operations.### `coderd_workspace_creation_total`* Metric type: Counter* Name: `coderd_workspace_creation_total`* Labels: `organization_name`, `template_name`, `preset_name`This counter tracks whether a regular workspace (not created from aprebuild pool) was created using a preset or not.Currently, we already expose `coderd_prebuilt_workspaces_claimed_total`for claimed prebuilt workspaces, but we lack a comparable metric forregular workspace creations. This metric fills that gap, making itpossible to compare regular creations against claims.Implementation notes:* Exposed as a `coderd_` metric, consistent with other workspace-relatedmetrics (e.g. `coderd_api_workspace_latest_build`:https://github.com/coder/coder/blob/main/coderd/prometheusmetrics/prometheusmetrics.go#L149).* Every `defaultRefreshRate` (1 minute ), DB query`GetRegularWorkspaceCreateMetrics` is executed to fetch all regularworkspaces (not created from a prebuild pool).* The counter is updated with the total from all time (not just sincemetric introduction). This differs from the histograms below, which onlyaccumulate from their introduction forward.### `coderd_workspace_creation_duration_seconds` &`coderd_prebuilt_workspace_claim_duration_seconds`* Metric types: Histogram* Names: * `coderd_workspace_creation_duration_seconds`* Labels: `organization_name`, `template_name`, `preset_name`, `type`(`regular`, `prebuild`) * `coderd_prebuilt_workspace_claim_duration_seconds` * Labels: `organization_name`, `template_name`, `preset_name`We already have `coderd_provisionerd_workspace_build_timings_seconds`,which tracks build run times for all workspace builds handled by theprovisioner daemon.However, in the context of this issue, we are only interested increation and claim build times, not all transitions; additionally, thismetric does not include `preset_name`, and adding it there wouldsignificantly increase cardinality. Therefore, separate more focusedmetrics are introduced here:* `coderd_workspace_creation_duration_seconds`: Build time to create aworkspace (either a regular workspace or the build into a prebuild pool,for prebuild initial provisioning build).* `coderd_prebuilt_workspace_claim_duration_seconds`: Time to claim aprebuilt workspace from the pool.The reason for two separate histograms is that:* Creation (regular or prebuild): provisioning builds with similar timemagnitude, generally expected to take longer than a claim operation.* Claim: expected to be a much faster provisioning build.#### Native histogram usageProvisioning times vary widely between projects. Using static bucketsrisks unbalanced or poorly informative histograms.To address this, these metrics use [Prometheus nativehistograms](https://prometheus.io/docs/specs/native_histograms/):* First introduced in Prometheus v2.40.0* Recommended stable usage from v2.45+* Requires Go client `prometheus/client_golang` v1.15.0+* Experimental and must be explicitly enabled on the server(`--enable-feature=native-histograms`)For compatibility, we also retain a classic bucket definition (alignedwith the existing provisioner metric:https://github.com/coder/coder/blob/main/provisionerd/provisionerd.go#L182-L189).* If native histograms are enabled, Prometheus ingests thehigh-resolution histogram.* If not, it falls back to the predefined buckets.Implementation notes:* Unlike the counter, these histograms are updated in real-time atworkspace build job completion.* They reflect data only from the point of introduction forward (nohistorical backfill).## Relates toCloses:#19528Native histograms tested in observability stack:coder/observability#501 parent9fd33a7 commit0ab345c
File tree
21 files changed
+699
-8
lines changed- cli
- coderd
- coderdtest
- database
- dbauthz
- dbmetrics
- dbmock
- queries
- prometheusmetrics
- provisionerdserver
- docs/admin
- integrations
- templates/extending-templates
- enterprise/coderd
- scripts/metricsdocgen
21 files changed
+699
-8
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 |
| - | |
69 |
| - | |
70 |
| - | |
71 | 65 |
| |
72 | 66 |
| |
73 | 67 |
| |
| |||
83 | 77 |
| |
84 | 78 |
| |
85 | 79 |
| |
| 80 | + | |
86 | 81 |
| |
87 | 82 |
| |
88 | 83 |
| |
89 | 84 |
| |
90 | 85 |
| |
| 86 | + | |
91 | 87 |
| |
92 | 88 |
| |
93 | 89 |
| |
94 | 90 |
| |
| 91 | + | |
| 92 | + | |
95 | 93 |
| |
96 | 94 |
| |
97 | 95 |
| |
98 | 96 |
| |
99 | 97 |
| |
100 | 98 |
| |
101 | 99 |
| |
| 100 | + | |
102 | 101 |
| |
103 | 102 |
| |
104 | 103 |
| |
| 104 | + | |
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| |||
280 | 280 |
| |
281 | 281 |
| |
282 | 282 |
| |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
283 | 289 |
| |
284 | 290 |
| |
285 | 291 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
241 | 241 |
| |
242 | 242 |
| |
243 | 243 |
| |
| 244 | + | |
| 245 | + | |
244 | 246 |
| |
245 | 247 |
| |
246 | 248 |
| |
| |||
1930 | 1932 |
| |
1931 | 1933 |
| |
1932 | 1934 |
| |
| 1935 | + | |
1933 | 1936 |
| |
1934 | 1937 |
| |
1935 | 1938 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
184 | 184 |
| |
185 | 185 |
| |
186 | 186 |
| |
| 187 | + | |
| 188 | + | |
187 | 189 |
| |
188 | 190 |
| |
189 | 191 |
| |
| |||
604 | 606 |
| |
605 | 607 |
| |
606 | 608 |
| |
| 609 | + | |
607 | 610 |
| |
608 | 611 |
| |
609 | 612 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2699 | 2699 |
| |
2700 | 2700 |
| |
2701 | 2701 |
| |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
2702 | 2709 |
| |
2703 | 2710 |
| |
2704 | 2711 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2177 | 2177 |
| |
2178 | 2178 |
| |
2179 | 2179 |
| |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
2180 | 2184 |
| |
2181 | 2185 |
| |
2182 | 2186 |
| |
|
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
230 | 230 |
| |
231 | 231 |
| |
232 | 232 |
| |
233 |
| - | |
| 233 | + | |
234 | 234 |
| |
235 | 235 |
| |
236 | 236 |
| |
|
0 commit comments
Comments
(0)