| 14 | ) |
| 15 | |
| 16 | func NewMetrics(reg prometheus.Registerer) (*Metrics, error) { |
| 17 | m := &Metrics{ |
| 18 | workspaceBuildsEnqueued: prometheus.NewCounterVec(prometheus.CounterOpts{ |
| 19 | Namespace: "coderd", |
| 20 | Name: "workspace_builds_enqueued_total", |
| 21 | Help: "Total number of workspace build enqueue attempts.", |
| 22 | }, []string{"provisioner_type", "build_reason", "transition", "status"}), |
| 23 | } |
| 24 | |
| 25 | if reg != nil { |
| 26 | if err := reg.Register(m.workspaceBuildsEnqueued); err != nil { |
| 27 | return nil, err |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return m, nil |
| 32 | } |
| 33 | |
| 34 | // RecordBuildEnqueued records a workspace build enqueue attempt. It determines |
| 35 | // the status based on whether an error occurred and increments the counter. |