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)
| 34 | // no user waiting) from user-initiated builds (regular workspace |
| 35 | // creation or prebuild claims). |
| 36 | func 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. |
no outgoing calls