recordBuildMetrics records the workspace build enqueue metric if metrics are configured. It determines the appropriate build reason label, using "prebuild" for prebuild operations instead of the database reason.
(job *database.ProvisionerJob, err error)
| 346 | // configured. It determines the appropriate build reason label, using "prebuild" |
| 347 | // for prebuild operations instead of the database reason. |
| 348 | func (b *Builder) recordBuildMetrics(job *database.ProvisionerJob, err error) { |
| 349 | if b.buildMetrics == nil { |
| 350 | return |
| 351 | } |
| 352 | if job == nil || !job.Provisioner.Valid() { |
| 353 | return |
| 354 | } |
| 355 | |
| 356 | // Determine the build reason for metrics. Prebuilds use BuildReasonInitiator |
| 357 | // in the database but we want to track them separately in metrics. |
| 358 | buildReason := string(b.reason) |
| 359 | if b.prebuiltWorkspaceBuildStage == sdkproto.PrebuiltWorkspaceBuildStage_CREATE { |
| 360 | buildReason = provisionerdserver.BuildReasonPrebuild |
| 361 | } |
| 362 | |
| 363 | b.buildMetrics.RecordBuildEnqueued(string(job.Provisioner), buildReason, string(b.trans), err) |
| 364 | } |
| 365 | |
| 366 | // buildTx contains the business logic of computing a new build. Attributes of the new database objects are computed |
| 367 | // in a functional style, rather than imperative, to emphasize the logic of how they are defined. A simple cache |
no test coverage detected