muhammadhuzaifa / telescope-guzzle-watcher
Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.
Installs: 135 569
Dependents: 0
Suggesters: 0
Security: 0
Stars: 93
Watchers: 3
Forks: 4
Open Issues: 1
Requires
- php: ^8.0.2|^8.1|^8.2
- guzzlehttp/guzzle: ^7.0
- illuminate/contracts: ^11.0|^10.0|^9.0
- laravel/telescope: ^5.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0|^7.9|^6.0
- orchestra/testbench: ^9.0|^8.0|^7.0
README
Telescope Guzzle Watcher
Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.
Once the installation and configurations are completed, you will be able to see the request logs under telescope/client-requests
Installation
You can install the package via composer:
composer require muhammadhuzaifa/telescope-guzzle-watcher
Usage
You can publish the config file with:
php artisan vendor:publish --tag="telescope-guzzle-watcher-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Except Request Headers |-------------------------------------------------------------------------- | | This value is used when you need to exclude the request headers from | being recorded under the telescope. You can exclude any number of | headers containing sensitive information | */ 'except_request_headers' => [], /* |-------------------------------------------------------------------------- | Except Response Headers |-------------------------------------------------------------------------- | | This value is used when you need to exclude the response headers from | being recorded under the telescope. You can exclude any number of | headers containing sensitive information | */ 'except_response_headers' => [], /* |-------------------------------------------------------------------------- | Enable URI Tags |-------------------------------------------------------------------------- | | This value is used for determining wether the watcher should parse the url | and add it's segments as telescope tags | | */ 'enable_uri_tags' => true, /* |-------------------------------------------------------------------------- | Exclude words from URI tags |-------------------------------------------------------------------------- | | This value is used when you need to exclude words or patterns that should | be excluded from the tags list | */ 'exclude_words_from_uri_tags' => [], /* |-------------------------------------------------------------------------- | Content Size Limit |-------------------------------------------------------------------------- | | This value is used when you need to limit the response content. | Default is 64. | */ 'size_limit' => null, ];
You can set the headers that needs to be excluded such as API Keys or other sensitive information. You can also tag uri segments by converting them into an array. This feature can be toggled true/false.
Edit config/telescope.php
file and add the watcher
return [ // other telescope configurations \MuhammadHuzaifa\TelescopeGuzzleWatcher\Watchers\TelescopeGuzzleWatcher::class, ];
The watcher depends on the Service Container
and every instance of guzzle client must be resolve using Service Container
.
$client = app(\GuzzleHttp\Client::class); // will work $client = new \GuzzleHttp\Client(); // will not work
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
Other Projects
- Laravel Pulse Guzzle Recorder
- Laravel Pulse Guzzle Recorder provide a custom recorder for intercepting http requests made via guzzlehttp/guzzle php library and log them into the Laravel Pulse Slow Outgoing Requests section.
License
The MIT License (MIT). Please see License File for more information.