External HTTP requests
Flare can collect information about the external HTTP requests that are being made from your application. This includes:
- The request method
- The request URL
- The request body size
- The request headers
- The response status code
- The response body size
- The response headers
This functionality is enabled by default, but you can disable it by ignoring the ExternalHttp
collect in config.php
:
use Spatie\FlareClient\Enums\CollectType;
'collects' => FlareConfig::defaultCollects(
ignore: [CollectType::ExternalHttp],
),
You can configure the maximum number of external HTTP requests tracked while collecting data in the case of an error as follows:
'collects' => FlareConfig::defaultCollects(
extra: [
CollectType::ExternalHttp->value => [
'max_items_with_errors' => 10,
],
]
),
Collecting Laravel's HTTP client requests
Requests made with the Laravel HTTP client are automatically collected by default; no additional setup is required.
Collecting Guzzle HTTP requests
Flare can automatically collect Guzzle HTTP requests. This is done by using a middleware that will be added to the Guzzle client:
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Spatie\LaravelFlare\Recorders\ExternalHttpRecorder\Guzzle\FlareMiddleware;
$stack = HandlerStack::create();
$stack->push(new FlareMiddleware());
$client = new Client([
'handler' => $stack,
]);
You can also use the FlareHandlerStack
, which requires less code:
use Spatie\LaravelFlare\Recorders\ExternalHttpRecorder\Guzzle\FlareHandlerStack;
$client = new Client([
'handler' => new FlareHandlerStack()
]);