Magento-specific functionality

New Relic's PHP agent includes support for automatic transaction naming for the Community and Enterprise editions of Magento 1 and 2. This document describes how this works and how you can use the automated names to track issues on your Magento application.

Magento 1

Transactions in Magento 1 applications are named based on the module, controller, and action that handle the request. For example, a transaction for the default customer account page will be named customer/account/index, which indicates that the indexAction() method in Mage_Customer_AccountController (the account controller in the customer module) was responsible for the transaction.

Magento 2

Normal web transactions in Magento 2 applications are named similarly to Magento 1 transactions: the transaction name encodes the module, controller, and action that handled the request. For example, a request handled by the Magento\Customer\Controller\Account\Index controller class will also be named customer/account/index.

Web APIs

Magento 2 also includes built-in support for web APIs. These are web services that are made available through REST and SOAP.

As of PHP agent version 7.0, New Relic supports automatically naming transactions that use this functionality. Previous versions of the PHP agent named web API transactions as unknown by default.

Magento 2 web APIs Comments
SOAP

SOAP transactions are named based on the service class and method that handled the request. For example, the transaction name Webapi/Soap/Magento\Catalog\Api\CategoryManagementInterface/getTree indicates that a SOAP request was handled by the getTree() method on the model implementing Magento\Catalog\Api\CategoryManagementInterface.

WSDL transactions are also named automatically: Webapi/Soap/WsdlList is used for transactions that return the list of available APIs, whereas Webapi/Soap/Wsdl is used for transactions that get the WSDL for a specific SOAP API.

REST

From Magento 2.1 onwards, REST transactions are named similarly to SOAP transactions. The only difference is that REST requests are prefixed with Webapi/Rest instead of Webapi/Soap.

On Magento 2.0, the PHP agent is unable to automatically name the specific service class and method that handled the transaction. Instead, REST requests currently receive the generic name FrontController/Magento\Webapi\Controller\Rest\Interceptor. This may be improved in a future PHP agent release. As a workaround, New Relic recommends using newrelic_name_transaction() in the service method if greater resolution is required.

FrontControllerInterface plugins

It is possible in Magento 2 to register a plugin or interceptor for the Magento\Framework\App\FrontControllerInterface interface to replace the default routing engine. For example, this is how the web API features operate.

If an interceptor is registered for Magento\Framework\App\FrontControllerInterface, the name of that class will be used as the default transaction name when using New Relic's PHP agent version 7.0 or higher. You can also use newrelic_name_transaction() for manual naming if needed.

Escape automatic transaction naming

If automatic transaction naming is not useful, you can override the PHP agent's automatic transaction naming by using the newrelic_name_transaction() API function.

For more help

Join the discussion about PHP in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.