Something went wrong. Try again.
Something went wrong. Try again.
870 B · 31 lines
PHP
at main
1234567891011121314151617181920212223242526272829303132<?php
namespace App\Command;
use Beberlei\Metrics\Collector\CollectorInterface;use Symfony\Component\Console\Attribute\AsCommand;use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Style\SymfonyStyle;
/** * The command-side counterpart of HomeController: same collector, same naming. * The flush is handled by the same listener, which is why it fires on * console.terminate as well as kernel.terminate. */#[AsCommand(name: 'app:ping', description: 'Records a metric, to check the telemetry pipeline end to end')]class PingCommand{ public function __construct( private readonly CollectorInterface $metrics, ) { }
public function __invoke(SymfonyStyle $io): int { $this->metrics->increment('ping.invoked');
$io->success('Recorded ping.invoked.');
return Command::SUCCESS; }}