Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.22.0 #433

Merged
merged 26 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7847cbf
Refactor Laravel specific MR helpers
imjoehaines Jan 28, 2021
8de4f25
Add a step to check the Laravel response
imjoehaines Jan 28, 2021
d92387e
Clean up more thoroughly after running MR
imjoehaines Jan 28, 2021
71ee889
Merge pull request #429 from bugsnag/maze-runner-tidy
imjoehaines Jan 29, 2021
7bd49e0
Add MR tests for OOMs with no OomBootstrapper
imjoehaines Jan 28, 2021
fb0aba9
Bump bugsnag-php version to 3.26.0
imjoehaines Jan 29, 2021
53011c8
Support 'memory_limit_increase' option
imjoehaines Jan 29, 2021
60c61c6
Add a bootstrapper to allow OOMs to be handled
imjoehaines Jan 29, 2021
4338416
Add MR tests for OOMs with the new bootstrapper
imjoehaines Jan 29, 2021
df113f1
Load the Client up-front
imjoehaines Jan 29, 2021
590cd8f
Add unit test to ensure config is picked up
imjoehaines Jan 29, 2021
6d5d698
Add changelog entry
imjoehaines Feb 1, 2021
ccb511f
Support the new discard classes option
imjoehaines Feb 3, 2021
b8fe71e
Add MazeRunner tests for discard classes
imjoehaines Feb 3, 2021
38b65ae
Add changelog entry
imjoehaines Feb 4, 2021
d9c8354
Add discard classes to facade methods
imjoehaines Feb 8, 2021
0ec6894
Support the new redacted keys option
imjoehaines Feb 8, 2021
2354d66
Add MazeRunner tests for redacted keys
imjoehaines Feb 8, 2021
a0c07ff
Add deprecation notice to filters
imjoehaines Feb 8, 2021
8dd3757
Add redacted keys to facade methods
imjoehaines Feb 8, 2021
88d6a32
Add redacted keys to changelog
imjoehaines Feb 8, 2021
e9c78f7
Merge pull request #430 from bugsnag/handle-ooms
imjoehaines Feb 10, 2021
86a7f18
Merge pull request #431 from bugsnag/discard-classes
imjoehaines Feb 10, 2021
9afef11
Merge pull request #432 from bugsnag/redacted-keys
imjoehaines Feb 10, 2021
389cbca
Add version to changelog
imjoehaines Feb 10, 2021
3a913a0
Update version
imjoehaines Feb 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .ci/patches/oom-bootstrapper.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 17b4866..d1dcc9e 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -67,4 +67,16 @@ class Kernel extends HttpKernel
'hanMidEx' => \App\Http\Middleware\HandledMiddlewareEx::class,
'hanMidErr' => \App\Http\Middleware\HandledMiddlewareErr::class,
];
+
+ protected function bootstrappers()
+ {
+ if (!getenv('BUGSNAG_REGISTER_OOM_BOOTSTRAPPER')) {
+ return parent::bootstrappers();
+ }
+
+ return array_merge(
+ [\Bugsnag\BugsnagLaravel\OomBootstrapper::class],
+ parent::bootstrappers(),
+ );
+ }
}
48 changes: 44 additions & 4 deletions .ci/patches/web-routes.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
diff --git a/routes/web.php b/routes/web.php
index b130397..4b89d73 100644
index b130397..0c687ad 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,5 +1,6 @@
<?php

+use App\Http\Controllers\TestController;
use Illuminate\Support\Facades\Route;

/*
@@ -16,3 +17,38 @@ use Illuminate\Support\Facades\Route;
@@ -16,3 +17,78 @@
Route::get('/', function () {
return view('welcome');
});
Expand Down Expand Up @@ -48,3 +48,43 @@ index b130397..4b89d73 100644
+Route::view('/unhandled_view_error', 'unhandlederror');
+Route::view('/handled_view_exception', 'handledexception');
+Route::view('/handled_view_error', 'handlederror');
+
+/**
+ * Return some diagnostics if an OOM did not happen when it should have.
+ *
+ * @return string
+ */
+function noOomResponse() {
+ $limit = ini_get('memory_limit');
+ $memory = var_export(memory_get_usage(), true);
+ $peak = var_export(memory_get_peak_usage(), true);
+
+ return <<<HTML
+ No OOM!
+ {$limit}
+ {$memory}
+ {$peak}
+ HTML;
+}
+
+Route::get('/oom/big', function () {
+ $a = str_repeat('a', 2147483647);
+
+ return noOomResponse();
+});
+
+Route::get('/oom/small', function () {
+ ini_set('memory_limit', memory_get_usage() + (1024 * 1024 * 5));
+ ini_set('display_errors', true);
+
+ $i = 0;
+
+ gc_disable();
+
+ while ($i++ < 12345678) {
+ $a = new stdClass;
+ $a->b = $a;
+ }
+
+ return noOomResponse();
+});
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
Changelog
=========

## 2.22.0 (2021-02-10)

### Enhancements

* Out of memory errors can now be reported by registering the new `OomBootstrapper` in your HTTP kernel, which will increase the memory limit by 5 MiB when an OOM occurs. See the docs for more details:
[Laravel](https://docs.bugsnag.com/platforms/php/laravel/#reporting-out-of-memory-exceptions)
[Lumen](https://docs.bugsnag.com/platforms/php/lumen/#reporting-out-of-memory-exceptions)
[#430](https://github.com/bugsnag/bugsnag-laravel/pull/430)

* Support the new `discardClasses` configuration option. This allows events to be discarded based on the exception class name or PHP error name.
[#431](https://github.com/bugsnag/bugsnag-laravel/pull/431)

* Support the new `redactedKeys` configuration option. This is similar to `filters` but allows both strings and regexes. String matching is exact but case-insensitive. Regex matching allows for partial and wildcard matching.
[#432](https://github.com/bugsnag/bugsnag-laravel/pull/432)

### Deprecations

* The `filters` configuration option is now deprecated as `redactedKeys` can express everything that filters could and more.

## 2.21.0 (2020-11-25)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": ">=5.5",
"bugsnag/bugsnag": "^3.20",
"bugsnag/bugsnag": "^3.26.0",
"bugsnag/bugsnag-psr-logger": "^1.4",
"illuminate/contracts": "^5.0|^6.0|^7.0|^8.0",
"illuminate/support": "^5.0|^6.0|^7.0|^8.0",
Expand Down
25 changes: 25 additions & 0 deletions config/bugsnag.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
| passwords, and credit card numbers to our servers. Any keys which
| contain these strings will be filtered.
|
| This option has been deprecated in favour of 'redacted_keys'
|
*/

'filters' => empty(env('BUGSNAG_FILTERS')) ? null : explode(',', str_replace(' ', '', env('BUGSNAG_FILTERS'))),
Expand Down Expand Up @@ -305,4 +307,27 @@

'build_endpoint' => env('BUGSNAG_BUILD_ENDPOINT'),

/*
|--------------------------------------------------------------------------
| Discard Classes
|--------------------------------------------------------------------------
|
| An array of classes that should not be sent to Bugsnag.
|
| This can contain both fully qualified class names and regular expressions.
|
*/

'discard_classes' => empty(env('BUGSNAG_DISCARD_CLASSES')) ? null : explode(',', env('BUGSNAG_DISCARD_CLASSES')),

/*
|--------------------------------------------------------------------------
| Redacted Keys
|--------------------------------------------------------------------------
|
| An array of metadata keys that should be redacted.
|
*/

'redacted_keys' => empty(env('BUGSNAG_REDACTED_KEYS')) ? null : explode(',', env('BUGSNAG_REDACTED_KEYS')),
];
29 changes: 29 additions & 0 deletions features/discard_classes.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Feature: Discard classes

Scenario: Exceptions can be discarded by name
Given I set environment variable "BUGSNAG_DISCARD_CLASSES" to "Exception"
And I start the laravel fixture
When I navigate to the route "/unhandled_controller_exception"
Then I should receive no requests

Scenario: Exceptions can be discarded by regex
Given I set environment variable "BUGSNAG_DISCARD_CLASSES" to "/Exception$/"
And I start the laravel fixture
When I navigate to the route "/unhandled_controller_exception"
Then I should receive no requests

Scenario: Exceptions will be delivered when discard classes does not match
Given I set environment variable "BUGSNAG_DISCARD_CLASSES" to "DifferentException,/^NotThatException$/"
And I start the laravel fixture
When I navigate to the route "/unhandled_controller_exception"
Then I wait to receive a request
And the request is valid for the error reporting API version "4.0" for the "Bugsnag Laravel" notifier
And the exception "errorClass" equals "Exception"
And the exception "message" starts with "Crashing exception!"
And the event "metaData.request.httpMethod" equals "GET"
And the event "app.type" equals "HTTP"
And the event "context" equals "GET /unhandled_controller_exception"
And the event "severity" equals "error"
And the event "unhandled" is true
And the event "severityReason.type" equals "unhandledExceptionMiddleware"
And the event "severityReason.attributes.framework" equals "Laravel"
12 changes: 12 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ services:
- BUGSNAG_SESSION_ENDPOINT
- BUGSNAG_CAPTURE_SESSIONS
- BUGSNAG_USE_CUSTOM_GUZZLE
- BUGSNAG_REGISTER_OOM_BOOTSTRAPPER
- BUGSNAG_DISCARD_CLASSES
- BUGSNAG_REDACTED_KEYS
restart: "no"
ports:
- target: 8000
Expand All @@ -27,6 +30,9 @@ services:
- BUGSNAG_SESSION_ENDPOINT
- BUGSNAG_CAPTURE_SESSIONS
- BUGSNAG_USE_CUSTOM_GUZZLE
- BUGSNAG_REGISTER_OOM_BOOTSTRAPPER
- BUGSNAG_DISCARD_CLASSES
- BUGSNAG_REDACTED_KEYS
restart: "no"
ports:
- target: 8000
Expand All @@ -43,6 +49,9 @@ services:
- BUGSNAG_SESSION_ENDPOINT
- BUGSNAG_CAPTURE_SESSIONS
- BUGSNAG_USE_CUSTOM_GUZZLE
- BUGSNAG_REGISTER_OOM_BOOTSTRAPPER
- BUGSNAG_DISCARD_CLASSES
- BUGSNAG_REDACTED_KEYS
restart: "no"
ports:
- target: 8000
Expand All @@ -59,6 +68,9 @@ services:
- BUGSNAG_SESSION_ENDPOINT
- BUGSNAG_CAPTURE_SESSIONS
- BUGSNAG_USE_CUSTOM_GUZZLE
- BUGSNAG_REGISTER_OOM_BOOTSTRAPPER
- BUGSNAG_DISCARD_CLASSES
- BUGSNAG_REDACTED_KEYS
restart: "no"
ports:
- target: 8000
Expand Down
12 changes: 12 additions & 0 deletions features/fixtures/laravel56/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,16 @@ class Kernel extends HttpKernel
'hanMidEx' => \App\Http\Middleware\HandledMiddlewareEx::class,
'hanMidErr' => \App\Http\Middleware\HandledMiddlewareErr::class,
];

protected function bootstrappers()
{
if (!getenv('BUGSNAG_REGISTER_OOM_BOOTSTRAPPER')) {
return parent::bootstrappers();
}

return array_merge(
[\Bugsnag\BugsnagLaravel\OomBootstrapper::class],
parent::bootstrappers(),
);
}
}
42 changes: 42 additions & 0 deletions features/fixtures/laravel56/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
|
*/

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
return view('welcome');
});
Expand Down Expand Up @@ -49,3 +51,43 @@
Route::view('/unhandled_view_error', 'unhandlederror');
Route::view('/handled_view_exception', 'handledexception');
Route::view('/handled_view_error', 'handlederror');

/**
* Return some diagnostics if an OOM did not happen when it should have.
*
* @return string
*/
function noOomResponse() {
$limit = ini_get('memory_limit');
$memory = var_export(memory_get_usage(), true);
$peak = var_export(memory_get_peak_usage(), true);

return <<<HTML
No OOM!
{$limit}
{$memory}
{$peak}
HTML;
}

Route::get('/oom/big', function () {
$a = str_repeat('a', 2147483647);

return noOomResponse();
});

Route::get('/oom/small', function () {
ini_set('memory_limit', memory_get_usage() + (1024 * 1024 * 5));
ini_set('display_errors', true);

$i = 0;

gc_disable();

while ($i++ < 12345678) {
$a = new stdClass;
$a->b = $a;
}

return noOomResponse();
});
12 changes: 12 additions & 0 deletions features/fixtures/laravel58/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,16 @@ class Kernel extends HttpKernel
*/
protected $middlewarePriority = [
];

protected function bootstrappers()
{
if (!getenv('BUGSNAG_REGISTER_OOM_BOOTSTRAPPER')) {
return parent::bootstrappers();
}

return array_merge(
[\Bugsnag\BugsnagLaravel\OomBootstrapper::class],
parent::bootstrappers(),
);
}
}
42 changes: 42 additions & 0 deletions features/fixtures/laravel58/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
|
*/

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
return view('welcome');
});
Expand Down Expand Up @@ -49,3 +51,43 @@
Route::view('/unhandled_view_error', 'unhandlederror');
Route::view('/handled_view_exception', 'handledexception');
Route::view('/handled_view_error', 'handlederror');

/**
* Return some diagnostics if an OOM did not happen when it should have.
*
* @return string
*/
function noOomResponse() {
$limit = ini_get('memory_limit');
$memory = var_export(memory_get_usage(), true);
$peak = var_export(memory_get_peak_usage(), true);

return <<<HTML
No OOM!
{$limit}
{$memory}
{$peak}
HTML;
}

Route::get('/oom/big', function () {
$a = str_repeat('a', 2147483647);

return noOomResponse();
});

Route::get('/oom/small', function () {
ini_set('memory_limit', memory_get_usage() + (1024 * 1024 * 5));
ini_set('display_errors', true);

$i = 0;

gc_disable();

while ($i++ < 12345678) {
$a = new stdClass;
$a->b = $a;
}

return noOomResponse();
});
12 changes: 12 additions & 0 deletions features/fixtures/laravel66/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,16 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];

protected function bootstrappers()
{
if (!getenv('BUGSNAG_REGISTER_OOM_BOOTSTRAPPER')) {
return parent::bootstrappers();
}

return array_merge(
[\Bugsnag\BugsnagLaravel\OomBootstrapper::class],
parent::bootstrappers(),
);
}
}
Loading