--- title: "ADR 0033: The running PipelineRuns gauge reports zero for repositories with only completed runs" --- * Status: accepted * Code: [`pkg/pipelinerunmetrics/metrics.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelinerunmetrics/metrics.go) (`ObserveRunningPRsMetrics`, `NewRecorder`) ## Context `pipelines_as_code_running_pipelineruns_count` is an observable gauge fed from the PipelineRun lister on every `ReportingPeriod` (30s by default). Only PipelineRuns carrying the `keys.Repository` annotation, that is those created by Pipelines-as-Code, are counted, grouped by `namespace/repository`. An observable gauge only exports the series that are observed in a callback. A repository whose last running PipelineRun finished would otherwise stop being observed and its series would vanish instead of dropping to zero. ## Decision `ObserveRunningPRsMetrics` keeps two sets while walking the list: the running count per key, and the keys that have at least one finished PipelineRun. After reporting the running counts, it reports `0` for every key in the finished set that has no running entry. ## Consequences * A repository that has no PipelineRun in the lister at all is not reported, since no key is ever recorded for it. * An empty PipelineRun list returns early and reports nothing.