MCPcopy Index your code
hub / github.com/coder/coder / NewLifecycleMetrics

Function NewLifecycleMetrics

coderd/agentapi/metrics.go:36–59  ·  view source on GitHub ↗

NewLifecycleMetrics creates and registers all lifecycle-related Prometheus metrics. The build duration histogram tracks the end-to-end duration from workspace build creation to agent ready, by template. It is recorded by the coderd replica handling the agent's connection when the last agent reports

(reg prometheus.Registerer)

Source from the content-addressed store, hash-verified

34// no user waiting) from user-initiated builds (regular workspace
35// creation or prebuild claims).
36func NewLifecycleMetrics(reg prometheus.Registerer) *LifecycleMetrics {
37 m := &LifecycleMetrics{
38 BuildDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
39 Namespace: "coderd",
40 Name: BuildDurationMetricName,
41 Help: "Duration from workspace build creation to agent ready, by template.",
42 Buckets: []float64{
43 1, // 1s
44 10,
45 30,
46 60, // 1min
47 60 * 5,
48 60 * 10,
49 60 * 30, // 30min
50 60 * 60, // 1hr
51 },
52 NativeHistogramBucketFactor: 1.1,
53 NativeHistogramMaxBucketNumber: 100,
54 NativeHistogramMinResetDuration: time.Hour,
55 }, []string{"template_name", "organization_name", "transition", "status", "is_prebuild"}),
56 }
57 reg.MustRegister(m.BuildDuration)
58 return m
59}
60
61// emitBuildDurationMetric records the end-to-end workspace build
62// duration from build creation to when all agents are ready.

Callers 2

NewFunction · 0.92
TestUpdateLifecycleFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestUpdateLifecycleFunction · 0.74