Search code examples
phpprofilingmonitoringnewrelicapdex

NewRelic - How to Ignore part of a PHP application


Is it possible to tell NewRelic to skip instrumentation from part of an application?

Let say I have an url:

www.example.com/?download=dwn_id

It takes minutes to tens of minutes for php processes the accomplish. I don't want to optimize the download, only skip it from the instrumentation as it is affecting NewRelic stats causing unnecessary alerts and affecting Apdex score.

Other example might be:

www.example.com/?task=cron

For a long running CRON jobs every minute, again this is not relevant for end-users thus worth skipping it.

It would make sense to skip theses parts of the app, I think, like any /admin backend resource as they are not relevant for the end-users.


Solution

  • Where you check if it is a cronjob, simply add:

    if (extension_loaded('newrelic')) {
        newrelic_ignore_transaction();
    }
    

    NewRelic will then not calculate any of the metrics for it. I've added this to a cronjob of my own.

    Source: https://docs.newrelic.com/docs/php/the-php-api