New Relic
a plugin for Craft CMS, (*1)
A Top Shelf Craft creation
Michael Rog, Proprietor, (*2)
Instrument your Craft app with New Relic APM., (*3)
tl:dr
This plugin helps connect your Craft app with New Relic APM by setting transaction names and (optionally) an app name on each request., (*4)
Installation
-
From your project directory, use Composer to require the plugin package:, (*5)
composer require topshelfcraft/new-relic
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for New Relic., (*6)
-
Add a new-relic.php
config file, edit the plugin Settings as needed., (*7)
The New Relic plugin is also available for installation via the Craft CMS Plugin Store., (*8)
Configuration
You can use the Control Panel settings screen to configure the plugin, or add a new-relic.php
file to your Craft config directory:, (*9)
<?php
return [
/*
* Specify a different app name than
* the one provided in your .ini files,
* e.g. If you want to change the app name
* on a per-environment basis...
*/
'appName' => '',
/*
* Specify a string to override Segment 2
* from the request path, e.g. If you want to
* consolidate your reported routes...
*/
'groupSegment2As' => '',
];
Enabling/Disabling for Testing
Leaving New Relic enabled when running test suites may cause problems — particularly when using CLI tools like Codeception — because Craft's isConsoleRequest()
method may return erroneously when bootstrapped in a testing context., (*10)
To disable New Relic during testing, add the plugin handle to disabledPlugins
, in the general.php
config file in your Testing setup:, (*11)
<?php
return [
// ...
'disabledPlugins' => [
'new-relic',
],
// ...
];
If you specifically need to use New Relic while running tests, you'll need to explicitly tweak the request in your test bootstrap:, (*12)
Yii:$app->request->setIsConsoleRequest(Yii:$app->request instanceof yii/console/Request);
What is New Relic?
New Relic provides tools for real-time monitoring and performance insight. When every aspect of your software and infrastructure is observable, you can can find and fix problems faster.
New Relic APM (Application Performance Monitoring) helps you build, deploy, and maintain great software by providing
detailed performance metrics for every aspect of your environment., (*13)
This plugin assumes you already have an account set up at newrelic.com and that you have
installed the APM tool in your environment., (*14)
(This plugin is an unofficial companion to your New Relic setup for Craft. New Relic APM is a trademark of New Relic, Inc.), (*15)
Support
What are the system requirements?
Craft 4.0+ and PHP 8.0+, (*16)
I found a bug.
Suuuuure you did., (*17)
I triple-checked. It's a bug.
Well then, thanks for looking out for me. Please open a GitHub Issue or submit a PR to the 4.x.dev
branch., (*18)
Contributors: