From 3c0caff4c339ef8289caf27927bf315364871738 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Thu, 9 Nov 2023 22:55:17 +0100 Subject: [PATCH] Update PHP docs regarding changes to the `ErrorHandler` (#8455) * Update PHP docs regarding changes to the `ErrorHandler` * Update src/platforms/php/common/integrations/index.mdx Co-authored-by: Shana Matthews * Update src/platforms/php/common/integrations/index.mdx Co-authored-by: Shana Matthews --------- Co-authored-by: Shana Matthews --- src/platforms/php/common/integrations/index.mdx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/platforms/php/common/integrations/index.mdx b/src/platforms/php/common/integrations/index.mdx index 65a41342e0c84..64a2c4450a155 100644 --- a/src/platforms/php/common/integrations/index.mdx +++ b/src/platforms/php/common/integrations/index.mdx @@ -23,7 +23,16 @@ To do so, it ensures that Sentry's `ErrorHandler` is registered, and adds a call This integration hooks into the global PHP `error_handler` and emits events when an error occurs. -To do so, it ensures that Sentry's `ErrorHandler` is registered, and adds a callback to it as an error listener. By default, the `ErrorHandler` reserves 10 kilobytes of memory to handle fatal errors. +To do so, it ensures that Sentry's `ErrorHandler` is registered, and adds a callback to it as an error listener. By default, the `ErrorHandler` reserves 16 KiB of memory to handle fatal errors. When handling out of memory errors, the `ErrorHandler` additionally increases the [`memory_limit`](https://www.php.net/manual/en/ini.core.php#ini.memory-limit) by an additional 5 MiB to have enough room to send the out of memory event to Sentry. This change is only done once and only affects the handling of the out of memory error. + +To change the amount of memory reserved for fatal error handling or the amount the `memory_limit` is increased when handling an out of memory error, you can register the fatal error handler yourself before calling `\Sentry\init(...)`: + +```php +// The amount of reserved memory every request (in bytes), this has to be a positive integer amount of bytes. Defaults to 16 KiB +$errorHandler = \Sentry\ErrorHandler::registerOnceFatalErrorHandler(16 * 1024); +// The amount of memory in bytes to increase the `memory_limit` to when handling a out of memory error, can also be set to `null` to disable increasing the `memory_limit`. Defaults to 5 MiB +$errorHandler->setMemoryLimitIncreaseOnOutOfMemoryErrorInBytes(5 * 1024 * 1024); +``` For some frameworks or projects, specific integrations are provided both officially and by third-party users that automatically register the error handlers. Please refer to their documentation.