PHP, Web Development, Yii Framework

Stop Newrelic from recording slow AJAX/general calls in Yii2

I recently had to stop Newrelic from recording my long polling tactics so I came up with:


namespace common\components;

use Yii;
use yii\base\Component;
use yii\base\BootstrapInterface;
use yii\web\Application;
use yii\web\Controller;

class Newrelic extends Component implements BootstrapInterface
	public $ignoreRoutes = [];
	public function bootstrap($app)
		// delay attaching event handler to the view component after it is fully configured
		$app->on(Controller::EVENT_BEFORE_ACTION, function () use ($app) {
	public function beforeAction($app)
			if(in_array(Yii::$app->getUrlManager()->parseRequest($app->request)[0], $this->ignoreRoutes)){

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s