2017 © Pedro Peláez
 

library lumen-newrelic

New Relic instrumentation for the Lumen framework

image

nordsoftware/lumen-newrelic

New Relic instrumentation for the Lumen framework

  • Thursday, January 25, 2018
  • by Jalle19
  • Repository
  • 14 Watchers
  • 9 Stars
  • 27,650 Installations
  • PHP
  • 2 Dependents
  • 1 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 24 % Grown

The README.md

lumen-newrelic

GitHub Actions status Scrutinizer Code Quality Coverage Status, (*1)

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., (*2)

Requirements

Usage

Installation

Run the following command to install the package through Composer:, (*3)

composer require nordsoftware/lumen-newrelic

Configuration

You don't have to set any config values if you are happy to rely on the content of your newrelic.ini file. However, it's possible to override the license and application name using environment variables or the .env file. This can be useful if you deploy the same app in multiple environments, and therefore need distinguished names for each., (*4)

Be aware that doing so can have a small performance impact on the app., (*5)

The environment variables available are:, (*6)

  • NEW_RELIC_OVERRIDE_INI (defaults to false)
  • NEW_RELIC_APP_NAME
  • NEW_RELIC_LICENSE_KEY

If you don't set NEW_RELIC_OVERRIDE_INI to true, the app will not override the newrelic.ini file, regardless of the value of the other two variables., (*7)

Check out the description in /config/newRelic.php for an explanation of the effect., (*8)

Bootstrapping

In bootstrap/app.php, replace the $app->singleton() call which registers the exception handler with the following snippet:, (*9)

$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., (*10)

Now, add the middleware too:, (*11)

$app->middleware([
    ...
    Nord\Lumen\NewRelic\NewRelicMiddleware::class,
]);

This will ensure that transactions are named properly., (*12)

Finally, register the service provider:, (*13)

$app->register(Nord\Lumen\NewRelic\NewRelicServiceProvider::class);

Ignoring certain exceptions

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:, (*14)

$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., (*15)

Customizing transaction names

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., (*16)

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., (*17)

Marking transactions as background jobs

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., (*18)

Running tests

Clone the project and install its dependencies by running:, (*19)

composer install

Run the following command to run the test suite:, (*20)

vendor/bin/phpunit

License

See LICENSE, (*21)

The Versions

25/01 2018

dev-develop

dev-develop

New Relic instrumentation for the Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sam Stenvall

12/12 2016

dev-master

9999999-dev

New Relic instrumentation for the Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sam Stenvall

12/12 2016

1.1.0

1.1.0.0

New Relic instrumentation for the Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sam Stenvall

09/12 2016

1.0.0

1.0.0.0

New Relic instrumentation for the Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sam Stenvall