Lines 100.00% 7 / 7
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 collectMetrics 100.00% 7 / 7 100.00% 1 / 1 2
13final readonly class DeployMetricSource implements RuntimeMetricSource
14{
15    /** @return list<MetricFamily> */
16    public function collectMetrics(RuntimeSnapshot $snapshot): array
17    {
18        $deploy = $snapshot->deploy;
19        $info = new MetricFamily('stewart_deploy_info', 'Commit the daemon runs while it polls for new ones; always 1.', MetricType::Gauge);
20        $failures = new MetricFamily('stewart_deploy_failures_total', 'New commits that failed stewart check and were not deployed.', MetricType::Counter);
21
22        if ($deploy !== null) {
23            $info->recordSample(MetricLabels::fromLabel('commit', $deploy->commit), 1);
24            $failures->recordSample(MetricLabels::none(), $deploy->failures);
25        }
26
27        return [$info, $failures];
28    }
29}