Package Data | |
---|---|
Maintainer Username: | alexrili |
Maintainer Contact: | sam.stenvall@nordsoftware.com (Sam Stenvall) |
Package Create Date: | 2019-10-24 |
Package Last Update: | 2019-10-24 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-30 15:23:16 |
Package Statistics | |
---|---|
Total Downloads: | 11,619 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 0 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This library provides New Relic instrumentation for the Lumen framework. When installed this library will ensure that your transactions are properly named and that your exceptions are properly logged in New Relic.
Run the following command to install the package through Composer:
composer require nordsoftware/lumen-newrelic
In bootstrap/app.php
, replace the $app->singleton()
call which registers the exception handler with the following
snippet:
$app->instance(
Illuminate\Contracts\Debug\ExceptionHandler::class,
new Nord\Lumen\ChainedExceptionHandler\ChainedExceptionHandler(
new \App\Exceptions\Handler(),
[new Nord\Lumen\NewRelic\NewRelicExceptionHandler()]
)
);
This will ensure that exceptions are correctly reported to New Relic.
Now, add the middleware too:
$app->middleware([
...
Nord\Lumen\NewRelic\NewRelicMiddleware::class,
]);
This will ensure that transactions are named properly.
Finally, register the service provider:
$app->register(Nord\Lumen\NewRelic\NewRelicServiceProvider::class);
By default the exception handler ignores exceptions of type
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
. You can customize the list of ignored exceptions by
passing an array to the exception handler's constructor:
$exceptionHandler = new Nord\Lumen\NewRelic\NewRelicExceptionHandler([
FooException::class,
BarException::class,
]);
If you don't want any exception to be ignored, pass an empty array to the constructor.
By default the transaction name will use the controller@action
assigned to the route. If that fails, it will use the
route's name. If no name is defined, it will fallback to just index.php
.
If this doesn't meet your requirements, extend the Nord\Lumen\NewRelic\NewRelicMiddleware
class and override the
getTransactionName()
method, then register that middleware class instead.
If you have a dedicated route for webhooks, notifications, or other long-running background tasks you can apply the
Nord\Lumen\NewRelic\NewRelicBackgroundJobMiddleware
to the route in question. This will mark the transaction as a
background job in New Relic so that long processing times don't skew your response time graphs.
Clone the project and install its dependencies by running:
composer install
Run the following command to run the test suite:
vendor/bin/phpunit
See LICENSE