2017 © Pedro Peláez
 

library slim-newrelic

New Relic instrumentation for the Slim framework

image

herloct/slim-newrelic

New Relic instrumentation for the Slim framework

  • Wednesday, March 1, 2017
  • by herloct
  • Repository
  • 1 Watchers
  • 1 Stars
  • 804 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 21 % Grown

The README.md

slim-newrelic

Build Status Test Coverage Code Climate license, (*1)

This library provides New Relic instrumentation for the Slim framework. When installed this library will ensure that your transactions are properly named and that your exceptions are properly logged in New Relic., (*2)

Using @nordsoftware's nordsoftware/lumen-newrelic as reference., (*3)

License

See LICENSE, (*4)

Requirements

Usage

Installation

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

composer require herloct/slim-newrelic

Bootstrapping

Example index.php., (*6)

$config = [
    'settings' => [
        'displayErrorDetails' => true,

        // These two are needed so new relic agent could work
        'addContentLengthHeader' => false,
        'determineRouteBeforeAppMiddleware' => true
    ],

    'errorHandler' => function ($c) {
        $agent = $c->get(\SobanVuex\NewRelic\Agent::class);
        $errorHandler = new \Slim\Handlers\Error($c->get('settings')['displayErrorDetails']);

        return new \Herloct\Slim\Handlers\NewRelicError($agent, $errorHandler);
    },

    \SobanVuex\NewRelic\Agent::class => function ($c) {
        $agent = new \SobanVuex\NewRelic\Agent(
            'Your Application Name',
            'YOUR_NEW_RELIC_LICENSE_KEY'
        );

        return $agent;
    },

    \Herloct\Slim\NewRelicTransactionMiddleware::class => function ($c) {
        $agent = $c->get(\SobanVuex\NewRelic\Agent::class);

        return new \Herloct\Slim\NewRelicTransactionMiddleware($agent);
    }
];

$app = new \Slim\App($config);
$app->add(\Herloct\Slim\NewRelicTransactionMiddleware::class);

$app->get('/hello/{name}', function ($request, $response, $args) {
    return $response->write("Hello " . $args['name']);
})->setName('say_hello');

$app->run();

Customizing transaction names

By default the transaction name will use the route's name. If that fails, it will use the route's pattern., (*7)

If this doesn't meet your requirements, extend the Herloct\Slim\NewRelicTransactionMiddleware class and override the getTransactionName() method, then register that middleware class instead., (*8)

Running tests

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

composer install

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

vendor/bin/phpunit

The Versions

01/03 2017

dev-master

9999999-dev

New Relic instrumentation for the Slim framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar herloct

slim-framework slim newrelic new-relic