djtarazona's avatar

New Relic now reports errors handled by custom exception handlers, breaking Laravel error pages

FYI to those using New Relic. New Relic recently updated their PHP agent to report exceptions handled by custom exception handlers, driving up the error rate metrics! This causes a major headache for Laravel users as Laravel uses HttpExceptions to render 404 and similar error pages.

I noticed this as New Relic began blowing up with NotFoundHttpException errors. I've spoken to New Relic support who cited the change in their change log. At this point, I can't figure out how to disable this behavior.

New Relic said they will speak with their engineers to determine the reach of this breaking change. If you use New Relic, I encourage you to contact them and express your concern.

From New Relic:

The major difference is, that the last resort exception handler set by http://php.net/set_exception_handler function will now be caught by New Relic and reported. Previously, handling your errors with your own error handler meant you did not see them in New Relic. We regularly received feature requests for the ability to see these errors which is the new functionality unveiled here.

Is the issue that you consider these issues/exceptions to be handled by your error handler to make these specific cases now work or is it that the error handler allows your application to function despite the error, but you don't want to see this error as it's unfixable?

What I'd like to do is take this scenario to our developers to see if your scenario was the intended use case with our changes.

Edit: I should mention that New Relic is actively looking into the issue and I haven't spoken with an engineer yet.

Our developers are based in Oregon, so are a good few hours behind me before they come on stream, so I won't get a hold of them until towards the end of our day here in Dublin. I'll take it to them at this point and get you a clear answer on if there are any options, if there are any configuration additions which can help ignore this change or in these cases ignore the errors specifically.

0 likes
3 replies
djtarazona's avatar

Hello everyone,

New Relic has acknowledged the issue with their PHP agent and Laravel 5.

I've spoken to our developers and it seems that they absolutely agree, in Laravel 5 we are instrumenting the exception handler and are reporting the errors and really should not be in your case.

They just gave me access to a new, pre-release build and it has fixed the issue for me. New Relic should be making the fix available in a public release soon! If you need early access, I suggest contacting New Relic support.

aurelien64's avatar

Actually I'd rather keep it. Getting a notification because there are 5% or more of 404s is quite sensible and useful, it would often point to some issue on your site. And that helps me review 404s on the site, anytime I'm looking at the errors report.

I was surprised and didn't like it at first, but I would like to keep it now, so if that could somehow be an opt-in or opt-out option that's be great.

Medology's avatar

This is still a problem for us. We have a Laravel site that is getting a large amount of HttpNotFoundExceptions in our New Relic logs due to bots attempting to probe the site for weaknesses.

Our current solution is to add a route that uses http_response_code() instead of Laravel's method of throwing HttpNotFoundException. This prevents the error from showing up in New Relic.

I agree with @aurelien64, that valid 404's showing up in New Relic are valuable. So maybe this approach is better than having New Relic ignore all HttpNotFoundExceptions?

Please or to participate in this conversation.