Skip to content

Commit

Permalink
Release v2.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines authored Feb 10, 2021
2 parents e2096f4 + 3a913a0 commit 89eb615
Show file tree
Hide file tree
Showing 22 changed files with 579 additions and 43 deletions.
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

0 comments on commit 89eb615

Please sign in to comment.