Skip to content

Commit c528791

Browse files
authored
feat: add workspace build timing metrics (coder#15771)
This PR introduces a new prometheus metrics for `workspace_build_timing_seconds`, which specifically reports workspace build times. To reduce cardinality, this metrics excludes `workspace_name` and `workspace_owner` that are present on the `workspace_builds_total` metrics.
1 parent ea9e39d commit c528791

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

provisionerd/provisionerd.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ func NewMetrics(reg prometheus.Registerer) Metrics {
178178
Name: "workspace_builds_total",
179179
Help: "The number of workspaces started, updated, or deleted.",
180180
}, []string{"workspace_owner", "workspace_name", "template_name", "template_version", "workspace_transition", "status"}),
181+
WorkspaceBuildTimings: auto.NewHistogramVec(prometheus.HistogramOpts{
182+
Namespace: "coderd",
183+
Subsystem: "provisionerd",
184+
Name: "workspace_build_timings_seconds",
185+
Help: "The time taken for a workspace to build.",
186+
Buckets: []float64{
187+
1, // 1s
188+
10,
189+
30,
190+
60, // 1min
191+
60 * 5,
192+
60 * 10,
193+
60 * 30, // 30min
194+
60 * 60, // 1hr
195+
},
196+
}, []string{"template_name", "template_version", "workspace_transition", "status"}),
181197
},
182198
}
183199
}

provisionerd/runner/runner.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ type Metrics struct {
8686
// JobTimings also counts the total amount of jobs.
8787
JobTimings *prometheus.HistogramVec
8888
// WorkspaceBuilds counts workspace build successes and failures.
89-
WorkspaceBuilds *prometheus.CounterVec
89+
WorkspaceBuilds *prometheus.CounterVec
90+
WorkspaceBuildTimings *prometheus.HistogramVec
9091
}
9192

9293
type JobUpdater interface {
@@ -189,6 +190,12 @@ func (r *Runner) Run() {
189190
build.Metadata.WorkspaceTransition.String(),
190191
status,
191192
).Inc()
193+
r.metrics.WorkspaceBuildTimings.WithLabelValues(
194+
build.Metadata.TemplateName,
195+
build.Metadata.TemplateVersion,
196+
build.Metadata.WorkspaceTransition.String(),
197+
status,
198+
).Observe(time.Since(start).Seconds())
192199
}
193200
r.metrics.JobTimings.WithLabelValues(r.job.Provisioner, status).Observe(time.Since(start).Seconds())
194201
}()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy