Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Relic Error Reporting - Stop Catching E_NOTICE errors

The issue I have right now is that it is hard to find actual bugs because so many E_NOTICEs are found. We have nearly 600 sites on our server with complicated scripts, and I've done a lot to handle a great deal of them, but there are still quite a few.

I receive an email and a text every time the error percentage is too high, which is great to prevent problems.

I'm sure I'm not the only one to encounter this problem -- is there a recommended solution? I've tried setting error_reporting( E_ALL ^ E_NOTICE ); but it hasn't stopped it.

One possible solution I've thought of is not setting New Relic as the error handler, using my own, and then sending them the error if it's not an E_NOTICE. Haven't figured out how to do this just yet.

like image 880
Kerry Jones Avatar asked Feb 17 '23 05:02

Kerry Jones


1 Answers

New Relics's PHP agent will not trace E_NOTICE errors unless you've explicitly used set_error_handler(newrelic_notice_error);

If you'd like New Relic to trace some but not all uncaught exceptions, creating your own error handler which calls newrelic_notice_error would make sense.

There is more information regarding this in the New Relic documentation: https://newrelic.com/docs/php/the-php-api

In most cases, it is not necessary, or advised, to set New Relic as the error handler.

like image 176
Steven Avatar answered Mar 07 '23 04:03

Steven