Guzzle middleware that logs Bugsnag breadcrumbs
Installs: 1 871
Open Issues: 0
- php: >=7.4
- bugsnag/bugsnag: ^3.20
- guzzlehttp/guzzle: ^7.2
- bugsnag/bugsnag-laravel: ^2.21
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: >=9.5
This package is auto-updated.
Last update: 2023-03-22 16:21:05 UTC
This is a middleware for Guzzle 7 that leaves Bugsnag breadcrumbs for all requests.
⚠️ Please make sure you don't log sensitive information to Bugsnag and properly configure this middleware to redact secrets. ⚠️
composer require swisnl/guzzle-bugsnag-breadcrumbs-middleware
use Bugsnag\Client as Bugsnag; use GuzzleHttp\Client as Guzzle; use GuzzleHttp\HandlerStack; use Swis\Guzzle\Bugsnag\BreadcrumbMiddleware; $bugsnag = Bugsnag::make(); $stack = HandlerStack::create(); $stack->push(new BreadcrumbMiddleware($bugsnag)); $client = new Guzzle(['handler' => $stack]);
Now when you send a request, a Bugsnag breadcrumb is logged with the following metadata:
- status code
- response body (summary), in case of client or server exceptions (status code >= 400)
Using Laravel? Simply use the factory method to create the middleware from the Bugsnag facade:
You can configure the middleware using the constructor arguments:
Your (preconfigured) Bugsnag client.
The name of the breadcrumb.
A list of secret strings, such as API keys, that should be filtered out of the metadata.
The length of the response body summary, which is added to the breadcrumb in case of client or server exceptions. Use null to disable logging response/request body.
By default, it does not log the request body and only logs the response body in case of client or server exceptions (status code >= 400). If you'd like to change this behaviour, you can provide your own
GuzzleHttp\BodySummarizerInterface implementation. You can use the default
GuzzleHttp\BodySummarizer for example, to log all request and response bodies. Please be aware not to log sensitive information!
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email email@example.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
SWIS ❤️ Open Source
SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.