diff --git a/src/backend/ci/core/metrics/biz-metrics/src/main/kotlin/com/tencent/devops/metrics/service/builds/MetricsUserService.kt b/src/backend/ci/core/metrics/biz-metrics/src/main/kotlin/com/tencent/devops/metrics/service/builds/MetricsUserService.kt index 6b1e5de6c65..20a2bfd62ab 100644 --- a/src/backend/ci/core/metrics/biz-metrics/src/main/kotlin/com/tencent/devops/metrics/service/builds/MetricsUserService.kt +++ b/src/backend/ci/core/metrics/biz-metrics/src/main/kotlin/com/tencent/devops/metrics/service/builds/MetricsUserService.kt @@ -331,6 +331,15 @@ class MetricsUserService @Autowired constructor( labels = labels ) local[key]?.meters?.add(buildGauge) + val buildStatusGauge = registerBuildStatusGauge( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + status = status, + description = "build status metrics for $buildId", + labels = labels + ) + local[key]?.meters?.add(buildStatusGauge) } CallBackEvent.BUILD_START -> { @@ -353,6 +362,7 @@ class MetricsUserService @Autowired constructor( ) local[key]?.meters?.add(buildStatusGauge) } + CallBackEvent.BUILD_JOB_QUEUE -> { val buildJobGauge = registerBuildJobQueueGauge( key = key, @@ -450,6 +460,9 @@ class MetricsUserService @Autowired constructor( metrics.meters.find { it.id.name == MetricsUserConfig.gaugeBuildQueueKey }?.run { metricsCacheService.removeCache(key) } + metrics.meters.find { it.id.name == MetricsUserConfig.gaugeBuildStatusKey }?.run { + metricsCacheService.removeCache(key) + } } CallBackEvent.BUILD_END -> {