networkteam / sentry_client

TYPO3 Extension for exception logging with sentry, see http://www.getsentry.com
33 stars 36 forks source link

Earlier instantiation #71

Closed christophlehmann closed 10 months ago

christophlehmann commented 1 year ago

Sentry has an Integration for catching Errors that occur when reaching memory_limit. Currently this is not active. The client needs to be setup earlier.

kitzberger commented 1 week ago

@christophlehmann, is this catching of "Allowed memory size ..." actually working in 5.1.1? Because I got nothing in Sentry on those incidents ;-(

I implemented something like this in config/system/additional.php to have them be reported to a Slack channel...

function shutdown()
{
    if ($error = error_get_last()) {
        if (str_contains($error['message'], 'Allowed memory size')) {
            $error['environment'] = (string)\TYPO3\CMS\Core\Core\Environment::getContext();
            $error['url'] = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

            // Slack webhook via cURL.
            ...

            exit();
        }
    }
}

register_shutdown_function('shutdown');

Maybe something like this could be implemented into EXT:sentry_client?