Skip to content

feat: add workspace build timing metrics #15771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions provisionerd/provisionerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ func NewMetrics(reg prometheus.Registerer) Metrics {
Name: "workspace_builds_total",
Help: "The number of workspaces started, updated, or deleted.",
}, []string{"workspace_owner", "workspace_name", "template_name", "template_version", "workspace_transition", "status"}),
WorkspaceBuildTimings: auto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "coderd",
Subsystem: "provisionerd",
Name: "workspace_build_timings_seconds",
Help: "The time taken for a workspace to build.",
Buckets: []float64{
1, // 1s
10,
30,
60, // 1min
60 * 5,
60 * 10,
60 * 30, // 30min
60 * 60, // 1hr
},
}, []string{"template_name", "template_version", "workspace_transition", "status"}),
},
}
}
Expand Down
9 changes: 8 additions & 1 deletion provisionerd/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ type Metrics struct {
// JobTimings also counts the total amount of jobs.
JobTimings *prometheus.HistogramVec
// WorkspaceBuilds counts workspace build successes and failures.
WorkspaceBuilds *prometheus.CounterVec
WorkspaceBuilds *prometheus.CounterVec
WorkspaceBuildTimings *prometheus.HistogramVec
}

type JobUpdater interface {
Expand Down Expand Up @@ -189,6 +190,12 @@ func (r *Runner) Run() {
build.Metadata.WorkspaceTransition.String(),
status,
).Inc()
r.metrics.WorkspaceBuildTimings.WithLabelValues(
build.Metadata.TemplateName,
build.Metadata.TemplateVersion,
build.Metadata.WorkspaceTransition.String(),
status,
).Observe(time.Since(start).Seconds())
}
r.metrics.JobTimings.WithLabelValues(r.job.Provisioner, status).Observe(time.Since(start).Seconds())
}()
Expand Down
Loading