jackwh/laravel-new-relic
Adds New Relic APM instrumentation to Laravel apps: names transactions by route, reports exceptions and custom metrics, and provides middleware plus config for queue jobs, ignored exceptions, and environment-specific settings. Simple setup for better Laravel performance monitoring.
Requirements for v1.4.0
v1.3.x; pin ^1.3 explicitly so an unrelated composer update doesn't surprise you.newrelic.so) must be installed and loaded in the SAPI that actually serves traffic. The package is a thin wrapper — without the extension it degrades to a no-op (which is intentional and is what makes local/test environments safe).Minimal setup
composer require jackwh/laravel-new-relicnewrelic.appname and newrelic.license in the agent's newrelic.ini, and confirm the daemon is running.php artisan vendor:publish and pick the package's config/provider) and commit config/newrelic.php.Where to look first
config/newrelic.php — transaction naming, ignored paths, custom attributes. This is where 90% of day-to-day tuning happens.First use case: give transactions meaningful names. Out of the box, New Relic tends to show raw URIs; configuring route-based naming turns /orders/8823 into orders.show, which is what makes APM transaction charts, error rates, and alerts actually usable.
Transaction naming
cli/queue and you can't alert on a specific job.Ignoring noise
/horizon, /telescope, /livewire/*, webhook receivers, and asset/prefetch hits to the ignored list. Ignored transactions still cost agent time but won't pollute your Apdex or error-rate baselines./foo is excluded.Custom attributes for segmentation
Auth::id() is populated.Queue jobs (changed behaviour in v1.4.0)
JobAttempted rather than JobProcessed. This is the important fix: JobProcessed never fires for a job that throws, so previously failed/retried jobs could leave the transaction dangling or mis-timed. Failed jobs now close cleanly and retries get their own correctly-scoped transaction.JobProcessed/JobFailed listeners. If you have custom listeners that call the New Relic end-transaction API, remove or guard them or you'll double-end.newrelic_start_transaction-style instrumentation around expensive sub-operations) over relying on total job duration.Environment strategy
newrelic.appname per environment so staging data never mixes with production.Integration tips
Laravel 10 drop is the real breaking change
composer.json and any downstream packages that pin this one. There are no code-level API changes to migrate.Extension loaded ≠ agent working
php -m in a container shell often checks the CLI SAPI, not FPM. Verify via a route that dumps extension_loaded('newrelic'), or check newrelic.daemon.* logs.newrelic.daemon.logfile and the socket path, especially across Docker/host boundaries.Naming cardinality explosions
Queue debugging
JobAttempted, a job that hangs will show a long transaction rather than an unclosed one. That's better, but it means "slow job" and "stuck job" look similar — use custom segments to distinguish.queue:work without --once) keep the agent's per-process state alive; restart workers on deploy so config/appname changes take effect.Testing
Extension points
How can I help you explore Laravel packages today?