Console commands
Flare can collect information about the console commands that are being executed. Whether an error happens during a command or you want to trace a long-running command, Flare will collect the following information:
- The command name
- The command arguments
- The exit code
This functionality is enabled by default, but you can disable it by ignoring the Commands collect in config.php:
use Spatie\FlareClient\Enums\CollectType;
'collects' => FlareConfig::defaultCollects(
ignore: [CollectType::Commands],
),
Ignoring specific commands
You can drop traces for individual commands by name or class. Names are matched against the command identifier (e.g. horizon:work), classes are matched against the fully qualified command class.
use Spatie\FlareClient\Enums\CollectType;
'collects' => FlareConfig::defaultCollects(
extra: [
CollectType::Commands->value => [
'ignored_commands' => ['horizon:*', 'schedule:run'],
'ignored_classes' => [App\Console\Commands\InternalCleanup::class],
],
],
),
Patterns are literal strings with * as a wildcard. When the ignored command is the top-level command, the trace is unsampled. When it runs nested inside another sampled trace, the recorder skips the inner span and resumes recording afterwards.
Manually recording commands
If you're running commands or subprocesses that aren't automatically tracked by Laravel, you can record them manually. The PHP documentation provides a full overview of all available recorder methods. When using these methods in Laravel, use the Flare facade instead of $flare:
use Spatie\LaravelFlare\Facades\Flare;
Flare::command()->recordStartFromDefined(
command: 'my:command',
arguments: ['--option' => 'value'],
);
// ... run the command
Flare::command()->recordEnd(exitCode: 0);
- On this page
- Ignoring specific commands
- Manually recording commands