dev-master
9999999-dev https://github.com/jeremyharris/cakephp-newrelicNew Relic is a plugin for CakePHP that makes transactions more useful
The Requires
by Jeremy Harris
plugin cakephp route new relic
New Relic is a plugin for CakePHP that makes transactions more useful
The New Relic plugin is a CakePHP plugin that makes your [New Relic] (https://newrelic.com) transactions easier to read and understand. It also gives you better flexibility in ignoring certain transactions (e.g., admin panels). By default, New Relic transactions are based on the file name and are hard to read. This plugin organizes them using basic routes, that is, a transaction for:, (*2)
/posts/edit/2
is placed in the following New Relic transaction:, (*3)
/posts/edit
This allows you to dig down into issues regarding certain actions, rather than based on filenames. To aggregate based on action, parameters are also ignored., (*4)
In your app directory type:, (*5)
git submodule add git://github.com/jeremyharris/cakephp-newrelic.git Plugin/NewRelic git submodule update --init
Ensure require
is present in composer.json
. This will install the plugin into Plugin/NewRelic:, (*6)
{ "require": { "jeremyharris/cakephp-newrelic": "dev-master" } }
Load the plugin:, (*7)
CakePlugin::loadAll(); // or CakePlugin::load('NewRelic');
Add the following filter to your Dispatch filters (in `bootstrap.php):, (*8)
Configure::write('Dispatcher.filters', array( 'AssetDispatcher', //default 'CacheDispatcher', //default 'NewRelic.NewRelicFilter' ));
Transactions will now be named by basic routes, that is, :controller/:action
., (*9)
Add the application name (in `bootstrap.php):, (*10)
Configure::write('NewRelic.appName', 'My App Name');
Sometimes you don't want to report something to New Relic. Things like importing take a while, and can mess up your averages. Admin panels are also an example of something you may not want to report to New Relic. You can ignore transactions based on routes like so:, (*11)
Configure::write('NewRelic.ignoreRoutes', array( '/admin/:controller/:action/*', '/users/import' ));
NewRelic.ignoreRoutes
uses the Routing system, so use them as you would connecting
a route in your routes.php
file., (*12)
If you want to use New Relic's RUM, there's a little helper that let's you do that. Add the helper to your controller:, (*13)
public $helpers = array( 'NewRelic.NewRelic' );
Then add the following to your layout:, (*14)
<!DOCTYPE html> <html> <head> <?php echo $this->NewRelic->start(); ?> ... </head> <body> ... <?php echo $this->NewRelic->end(); ?> </body> </html>
Copyright (c) Jeremy Harris, (*15)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*16)
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*17)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*18)
New Relic is a plugin for CakePHP that makes transactions more useful
plugin cakephp route new relic