Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
    • Back to Flare ⌘↵ Shortcut: Command or Control Enter
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript React React Vue Vue Protocol Protocol
  • General
  • Installation
  • Integrating into a framework
  • Attribute providers
  • Application lifecycle
  • Censoring collected data
  • Ignoring collected data
  • Flare daemon
  • Errors
  • Introduction
  • Customise error report
  • Customising error grouping
  • Linking to errors
  • Logs
  • Introduction
  • Levels
  • With errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and events
  • Data Collection
  • Application info
  • Cache events
  • Console commands
  • Custom context
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Jobs and queues
  • Queries
  • Redis commands
  • Requests
  • Routing
  • Server info
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Flare Client PHP V2
  • Flare Client PHP V1

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

It is possible to disable this behaviour by ignoring commands in the Flare config:

$config->ignoreCommands();

You can configure the maximum number of commands tracked while collecting data in the case of an error as such:

$config->collectCommands(maxItemsWithErrors: 3);

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.

$config->collectCommands(
    ignoredCommands: ['horizon:*', 'schedule:run'],
    ignoredClasses: [App\Console\Commands\InternalCleanup::class],
);

Patterns are literal strings with * as a wildcard (the same syntax used by sampling rules).

When the ignored command is the top-level command, the trace is unsampled. When it runs nested inside another sampled trace (for example, a synchronous subcommand), the recorder skips the inner span and resumes recording afterwards.

Collecting commands

The command recorder accepts a command attribute provider. Use the helpers below for the common cases.

$flare->command()->recordStartFromCli('my:command', commandClass: MyCommand::class);

For Symfony Console (or framework) commands that hand you an InputInterface, use the Symfony helper so the named arguments and options are captured:

$flare->command()->recordStartFromSymfonyInput('my:command', $input, MyCommand::class);

When you already have the resolved arguments as an array, use recordStartFromDefined:

$flare->command()->recordStartFromDefined(
    command: 'my:command',
    arguments: ['--option' => 'value'],
    commandClass: MyCommand::class,
);

The recorder sets the entry point for the trace to cli and fills in the handler attributes from the command class. You do not need to interact with EntryPointResolver directly.

Extra attributes can be passed alongside the standard ones:

$flare->command()->recordStartFromCli('my:command', attributes: [
    'process.pid' => 80,
]);

When the command ends (or fails), call recordEnd with the exit code:

$flare->command()->recordEnd(exitCode: 0);

Extra attributes can be added when the command ends as well:

$flare->command()->recordEnd(exitCode: 0, attributes: [
    'process.pid' => 80,
]);
Cache events Custom context
  • On this page
  • Ignoring specific commands
  • Collecting commands

Catch errors and fix slowdowns with Flare, the full-stack application monitoring platform for Laravel, PHP & JavaScript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Insights
  • Newsletter
  • Changelog
  • Documentation
  • Affiliate program
  • uptime status badge Service status
  • Terms of use
  • DPA
  • Privacy & cookie Policy
Made in by
Flare