Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newrelic php agent error tracing

Tags:

php

newrelic

I am a bit confused about how New Relic tracks errors in a php application.

Does the error level set in the application (with error_reporting()) matter for the php agent? Or does it still get all errors? Are there cases in which the php agent will not be able to gather errors?

like image 911
spdionis Avatar asked Feb 12 '23 07:02

spdionis


2 Answers

The New Relic PHP agent hooks into PHP and any errors that hit the PHP error handler will be passed on to us. We typically ignore 4xx errors but anything else detected by PHP should get collected.

As we're listening for errors detected by PHP, changing the error level will also affect the level of errors New Relic can see. Ee will never report errors with a level of E_NOTICE or E_USER_NOTICE

Errors with the web-server which prevent the PHP extension from loading will not be tracked. There's also a known compatibility issue with Xdebug which prevents our agent from tracking errors.

like image 82
karlpcrowley Avatar answered Feb 14 '23 22:02

karlpcrowley


As I am aware the best approach is to configure the agent using PHP agent (newrelic.ini) settings, the is the option newrelic.loglevel where you can set the log level. Although you can still use the error_reporting() to 'overwrite' those settings a relevant question / answer can be found here.

So as from my experience, there are some occasion that this is not working as I expected. Some time when a fatal error occurred, the php agent was unable to track it. Also there where times that new relic was resetting the options I have put using the error_reporting() to the 'default' ones I have set via newrelic.loglevel.
Disclaimer : I have over a year to use new relic so this may be obsolete.

My opinion is not to mix the these two different ways of setting the error level and stick with the API that the php agent provides. I think that in most of the cases this is going to be enough

like image 22
Athafoud Avatar answered Feb 14 '23 21:02

Athafoud