from PHP agent to real transaction visibility
Watching Magento through server load alone shows symptoms, not causes. New Relic makes individual transactions visible, from a checkout request down to an external payment service, giving you the data to fix performance problems on purpose instead of by guesswork.
Table of Contents
- 1. Why New Relic shows more than server metrics ever could
- 2. Installing the PHP agent and connecting it to Magento
- 3. Understanding transactions: web transactions and background jobs
- 4. Custom instrumentation for your own modules
- 5. Watching checkout and payment integration closely
- 6. Keeping an eye on indexing, cron, and message queues
- 7. Configuring alerts and NRQL queries properly
- 8. Keeping sampling, cost, and privacy under control
- 9. New Relic compared to other monitoring approaches
- 10. Summary
- 11. FAQ
1. Why New Relic shows more than server metrics ever could
Classic server monitoring answers whether CPU and RAM are under load, not why a customer waits three seconds for a checkout response. New Relic addresses exactly that gap: it instruments the PHP process itself and records how long each method takes, which database query dominates a transaction, and which external call, say to a payment provider, drives up response time. For a Magento store with many modules, plugins, and external integrations, that is the difference between guessing and knowing.
The value of New Relic shows up clearly after a release causes a performance regression. A new plugin slows down an observer chain, but server load stays unremarkable because the extra work spreads across many small requests. Without transaction tracing, this problem can stay hidden for days until customers complain. With New Relic, the slowed method shows up immediately in the transaction trace, with exact timing and call hierarchy, so the responsible module gets identified in minutes rather than days.
The third reason New Relic pays off for Magento is that it connects infrastructure and application layers in a single view. Instead of switching between a server dashboard, a database monitor, and application logs, one transaction shows exactly how much time was spent in PHP, how much in MySQL, how much in Redis, and how much in external HTTP calls. This end to end view is the foundation of any serious observability strategy for a Magento store.
2. Installing the PHP agent and connecting it to Magento
The New Relic PHP agent installs as a native package, not as a Composer dependency, because it loads as a PHP extension into the interpreter. On Debian based systems, installation goes through the official APT repository, followed by configuration in newrelic.ini. The license key and application name live there, and for Magento a clear naming convention pays off, such as Magento-Production and Magento-Staging, so data from different environments never mixes.
After installation, PHP FPM needs a restart for the agent to load. A common mistake is enabling the agent only for CLI but not for the FPM pool, or the other way around, since Magento cron jobs run via CLI while web requests are served through FPM. Both contexts need their own agent configuration, otherwise either the web transactions or the background jobs go missing in New Relic.
# Add the New Relic APT repository and install the PHP agent
echo "deb http://apt.newrelic.com/debian/ newrelic non-free" \
| sudo tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-php5
# Configure the agent for the Magento production application
sudo newrelic-install install
sudo sed -i 's/newrelic.appname = ".*"/newrelic.appname = "Magento-Production"/' \
/etc/php/8.3/mods-available/newrelic.ini
# Restart both contexts that run Magento code
sudo systemctl restart php8.3-fpm
sudo phpenmod newrelic
sudo systemctl restart cron
3. Understanding transactions: web transactions and background jobs
New Relic fundamentally separates web transactions, triggered by an HTTP request, from background transactions, produced by cron jobs or message queue consumers. For Magento this split matters, because a store with a slow indexer can look perfectly fine in the web frontend while a reindex job takes minutes instead of seconds in the background. Without this distinction, both kinds of load land in the same overview and distort the picture of actual application behavior.
In the New Relic transaction overview, web transactions can be grouped by controller action, meaning every route like catalog/product/view or checkout/cart/add shows up as its own row with average time, throughput, and error rate. This granularity lets you pinpoint the ten slowest actions instead of trusting a single aggregated response time that hides real outliers.
4. Custom instrumentation for your own modules
The standard agent automatically instruments well known frameworks and database drivers, but custom Magento modules, especially complex service classes, stay invisible without extra configuration. The New Relic PHP API lets you insert custom segments into a transaction, so an expensive price calculation service or an external API call shows up as its own named block in the transaction trace.
A proven pattern is wrapping instrumentation around central service classes via a plugin instead of annotating every method by hand. That keeps the core logic untouched while New Relic automatically captures time and call count for every instance of the class. For Magento this works particularly well for price rules, discount logic, and shipping cost calculation, since these areas often carry the heaviest customizations and are therefore prone to performance regressions.
<?php
declare(strict_types=1);
namespace Mironsoft\Observability\Plugin;
/**
* Wraps expensive service calls in a named New Relic custom segment
* so slow pricing calculations show up as their own block in traces.
*/
class NewRelicSegmentPlugin
{
/**
* Measures the wrapped method as a custom New Relic transaction segment.
*
* @param object $subject The instrumented service instance.
* @param callable $proceed The original method call.
* @param mixed ...$args Original method arguments.
* @return mixed The original method return value.
*/
public function aroundCalculate(object $subject, callable $proceed, ...$args): mixed
{
if (!\extension_loaded('newrelic')) {
return $proceed(...$args);
}
\newrelic_start_segment('PriceCalculation/' . \get_class($subject));
try {
return $proceed(...$args);
} finally {
\newrelic_end_segment();
}
}
}
5. Watching checkout and payment integration closely
Checkout is the area where every millisecond of load time directly affects conversion rate, and at the same time the area with the most external dependencies. Payment providers, tax services, and fraud checks often run synchronously inside the checkout transaction. New Relic shows in the transaction trace exactly how long the external HTTP call to the payment provider takes, separated from your own processing time.
Especially valuable is combining error rate and latency per external service. When a payment provider is occasionally slow without failing outright, classic uptime checks miss it entirely, yet it causes measurable revenue loss through abandoned carts. New Relic exposes such partial degradations before they escalate into a full outage, enabling proactive rather than reactive action in the checkout area.
6. Keeping an eye on indexing, cron, and message queues
Magento's indexers, cron jobs, and message queue consumers run outside the typical web request cycle, but they are just as prone to performance problems as checkout. A stuck consumer for the order export queue often goes unnoticed for days while messages pile up in the queue. New Relic captures background transactions the same way it captures web transactions, provided the agent is configured correctly in the CLI context.
For cron jobs, explicitly naming the transaction via newrelic_name_transaction() is worthwhile, so each job shows up under its own name instead of the generic cron.php. Without this naming, all cron tasks blur into a single aggregate metric, and a single slow job, say cleaning up old session data, can no longer be examined in isolation.
<?php
declare(strict_types=1);
namespace Mironsoft\Observability\Cron;
/**
* Names the current New Relic transaction after the concrete cron job
* so background tasks appear individually instead of under cron.php.
*/
class NamedCronJob
{
/**
* Runs the scheduled task under a distinct New Relic transaction name.
*
* @return void
*/
public function execute(): void
{
if (\extension_loaded('newrelic')) {
\newrelic_name_transaction('Cron/OrderExportQueue');
}
// Actual export logic goes here
}
}
7. Configuring alerts and NRQL queries properly
Raw data alone prevents no outage if nobody looks at it in time. New Relic alerts rely on NRQL, an SQL like query language that lets you formulate precise conditions, such as an error rate above two percent in the checkout transaction over a five minute window. Such targeted alerts are far more meaningful than a blanket CPU threshold, because they tie directly to business critical flows.
A proven pattern is tiering alert thresholds: a warning at moderate degradation, a critical alarm at a serious breach. For a Magento store this means, for instance, triggering a warning at an average checkout response time above 800 milliseconds and only paging the on call team above two seconds. This tiering prevents alert fatigue without missing genuine incidents.
{
"nrql": {
"query": "SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = 'Magento-Production' AND name LIKE '%checkout/cart%' SINCE 5 minutes ago"
},
"terms": [
{ "duration": 5, "operator": "above", "priority": "critical", "threshold": 2 },
{ "duration": 5, "operator": "above", "priority": "warning", "threshold": 1 }
],
"type": "NRQL"
}
8. Keeping sampling, cost, and privacy under control
Fully tracing every single transaction on a high traffic Magento store generates significant data volume, which directly affects the cost of a New Relic license. Sampling reduces the number of fully captured traces while aggregated metrics still get computed from every transaction. This balance between detail depth and data volume needs deliberate configuration rather than blind trust in the default setting.
From a privacy standpoint, it matters that transaction names and custom attributes never contain personal data, such as customer names or email addresses in URL parameters. New Relic offers the ability to exclude sensitive parameters from capture via an ignore list, which every Magento installation should review before going live, particularly regarding GDPR compliance for checkout and customer data.
9. New Relic compared to other monitoring approaches
New Relic is not the only option for Magento observability, and the choice depends on budget, team size, and how much control you want over your own infrastructure. The overview below places common approaches by their typical use case.
| Approach | Strength | Weakness | Good fit for |
|---|---|---|---|
| New Relic APM | Ready made instrumentation, transaction traces, NRQL alerts | License cost at high traffic | Teams without their own observability stack |
| Blackfire profiling | Very deep code profiles per request | No continuous live monitoring | Targeted debugging of individual requests |
| Self hosted OpenTelemetry | Full control, no vendor lock in | High operational effort for collectors and storage | Teams with their own observability platform |
| Server monitoring alone | Simple, cheap, quick to set up | No visibility into individual transactions | Pure infrastructure baseline monitoring |
In practice, these approaches often complement each other rather than exclude one another. Many Magento operators use New Relic for ongoing monitoring and additionally reach for a profiling tool for deeper analysis of individual requests. What matters is that at least one tool makes transactions traceable across system boundaries, instead of relying on isolated server metrics.
Mironsoft
Magento observability, performance analysis, and monitoring setup
Full transaction visibility for your Magento store?
We set up New Relic for Magento, instrument your custom modules, and build alerts that actually warn you before revenue is lost, not just before CPU load spikes.
Agent setup
New Relic PHP agent configured correctly for FPM and CLI
Custom instrumentation
Custom segments for price rules, checkout, and payment integration
Alert design
NRQL alerts tiered by warning and critical incident
10. Summary
New Relic turns Magento monitoring from pure server watching into real transaction observation. The PHP agent automatically captures web transactions and background jobs, while custom instrumentation exposes your own modules and service classes that would otherwise disappear as a black box in the transaction trace. Especially in checkout, where external payment providers affect response time, New Relic supplies the data to cleanly separate cause from effect.
The biggest lever is tying alerts directly to business critical transactions instead of generic infrastructure thresholds. A tiered alert configuration built on NRQL, combined with deliberate sampling against runaway cost, makes New Relic a sustainable part of the operating strategy for any production Magento store.
Monitoring Magento with New Relic — The key takeaways
Agent configuration
Enable the PHP agent separately for FPM and CLI, otherwise web transactions or cron jobs go missing in New Relic.
Custom instrumentation
newrelic_start_segment() and newrelic_name_transaction() make your own modules and cron jobs visible.
Checkout focus
Trace external payment providers separately to catch partial degradation before a full outage.
Alerts & cost
Tier NRQL alerts deliberately, configure sampling consciously, and exclude sensitive parameters from capture.