Developed with love by KnpLabs Hire us for your project!
136

EkinoNewRelicBundle

by ekino

Add NewRelic support to Symfony2

Ekino NewRelic Bundle

Build Status

This bundle integrates the NewRelic PHP API into Symfony2. For more information about NewRelic, please visit http://newrelic.com.

The bundle can use either the route name or the controller name as the transaction name. For CLI commands the transaction name is the command name.

Result

Ekino NewRelicBundle

Installation

Step 0 : Install NewRelic

review http://newrelic.com ...

Step 1: Using Composer (recommended)

Use composer.phar:

$ php composer.phar require ekino/newrelic-bundle

You just have to specify the version you want : master-dev.
It will add the package in your composer.json file and install it.

Or you can do it by yourself, first, add the following to your composer.json file:

// composer.json
{
    // ...
    require: {
        // ...
        "ekino/newrelic-bundle": "master-dev"
    }
}

Then, you can install the new dependencies by running Composer's update
command from the directory where your composer.json file is located:

$ php composer.phar update ekino/newrelic-bundle

Step 1 (alternative) : Using deps file (Symfony 2.0.x)

First, checkout a copy of the code. Just add the following to the deps
file of your Symfony Standard Distribution:

[EkinoNewRelicBundle]
    git=http://github.com/ekino/EkinoNewRelicBundle.git
    target=/bundles/Ekino/Bundle/NewRelicBundle

Then, run

$ bin/vendors install

Make sure that you also register the namespace with the autoloader:

<?php

// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Ekino'              => __DIR__.'/../vendor/bundles',
    // ...
));

Step 2 : Register the bundle

Then register the bundle with your kernel:

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Ekino\Bundle\NewRelicBundle\EkinoNewRelicBundle(),
    // ...
);

Step 3 : Configure the bundle

# app/config/config.yml

ekino_new_relic:
    enabled: true                         # Defaults to true
    application_name: Awesome Application # Application name (optional, default value is read from php.ini)
    api_key:                              # New Relic API
    license_key:                          # New Relic license key (optional, default value is read from php.ini)
    xmit: false                           # if you want to record the metric data up to the point newrelic_set_appname is called, set this to true
    logging: false                        # If true, logs all New Relic interactions to the Symfony log
    instrument: false                     # If true, uses enhanced New Relic RUM instrumentation (see below)
    log_exceptions: false                 # If true, sends exceptions to New Relic
    log_commands: true                    # If true, logs CLI commands to New Relic as Background jobs (>2.3 only)
    using_symfony_cache: false            # Symfony HTTP cache (see below)
    transaction_naming: route             # route, controller or service (see below)
    transaction_naming_service: ~         # Transaction naming service (see below)
    ignored_routes: []                    # No transaction recorded for this routes
    ignored_paths: []                     # No transaction recorded for this paths
    ignored_commands: []                  # No transaction recorded for this commands (background tasks)

Enhanced RUM instrumentation

The bundle comes with an option for enhanced real user monitoring. Ordinarily the New Relic extension (unless disabled by configuration) automatically adds a tracking code for RUM instrumentation to all HTML responses. Using enhanced RUM instrumentation, the bundle allows you to selectively disable instrumentation on certain requests.

This can be useful if, e.g. you're returning HTML verbatim for an HTML editor.

If enhanced RUM instrumentation is enabled, you can disable instrumentation for a given request by passing along a _instrument request parameter, and setting it to false. This can be done e.g. through the routing configuration.

Transaction naming strategies

The bundle comes with two built-in transaction naming strategies. route and controller, naming the New Relic transaction after the route or controller respectively. However, the bundle supports custom transaction naming strategies through the service configuration option. If you have selected the service configuration option, you must pass the name of your own transaction naming service as the transaction_naming_service configuration option.

The transaction naming service class must implement the Ekino\Bundle\NewRelicBundle\TransactionNamingStrategy\TransactionNamingStrategyInterface interface. For more information on creating your own services, see the Symfony documentation on Creating/Configuring Services in the Container.

Symfony HTTP Cache

When you are using Symfony's HTTP cache your app/AppCache.php will build up a response with your Edge Side Includes (ESI). This will look like one transaction in New Relic. When you set using_symfony_cache: true will these ESI request be separate transaction which improves the statistics. If you are using some other reverse proxy cache or no cache at all, leave this to false.

If true is required to set the application_name.

Deployment notification

You can use the newrelic:notify-deployment command to send deployment notifications to New Relic. This requires the api_key configuration to be set.

The command has a bunch of options, as displayed in the help data.

$ app/console newrelic:notify-deployment --help
Usage:
 newrelic:notify-deployment [--user[="..."]] [--revision[="..."]] [--changelog[="..."]] [--description[="..."]]

Options:
 --user         The name of the user/process that triggered this deployment
 --revision     A revision number (e.g., git commit SHA)
 --changelog    A list of changes for this deployment
 --description  Text annotation for the deployment — notes for you

The bundle provide a Capifony recipe to automate the deployment notifications (see Resources/recipes/newrelic.rb).

Integration with SonataBlockBundle

Step 0: Install SonataBlockBundle

Review SonataBlockBundle

Step 1: Enable your block:

# app/config/config.yml

sonata_block:
    blocks:
        ekino.newrelic.block.simple:
        ekino.newrelic.block.tabs:

Integration with SonataAdminBundle

Step 0: Install SonataBlockBundle

Review preview section

Step 1: Install SonataAdminBundle

Review SonataAdminBundle installation

Step 1: Enable your block:

# app/config/config.yml
sonata_block:
    blocks:
        ekino.newrelic.block:
...
sonata_admin:
    ...
    dashboard:
        blocks:
            - {
                position: left,
                type: ekino.newrelic.block.simple,
                settings: {
                    reference: 3Y5rCib3JmH   # Url charts (https://... or 3Y5rCib3JmH)
                }
              }

More details for configuration SonataAdminBundle

Integration with Twig

{{ sonata_block_render({ 'type': 'ekino.newrelic.block.simple' }, {
    'reference': '3Y5rCib3JmH'
}) }}

More details for Twig extension

The MIT License

Copyright (c) 2012 Ekino - thomas.rabaix@ekino.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
ekino_new_relic:
enabled: true
api_key: false
license_key: false
application_name: false
xmit: false
logging: false
instrument: false
log_exceptions: false
log_commands: true
transaction_naming: route
transaction_naming_service: ~
ignored_routes: []
ignored_paths: []
ignored_commands: []
using_symfony_cache: false
  • Merge pull request #80 from EmmanuelVella/command-response
    By rande, 2 years ago
  • Improve command error reporting
    By emmanuelvella, 2 years ago
  • Merge pull request #79 from EmmanuelVella/default-ini
    By rande, 2 years ago
  • Merge pull request #85 from thormeier/twig-extensions-for-rum
    By rande, 2 years ago
  • Make twig functions html save
    By thormeier, 2 years ago
  • Fix tests
    By thormeier, 2 years ago
  • Fix test
    By thormeier, 2 years ago
  • Fix twig method name typo
    By thormeier, 2 years ago
  • Fix method calls in tests
    By thormeier, 2 years ago
  • Add fixes for method name and service tag for twig
    By thormeier, 2 years ago
  • Merge pull request #84 from thormeier/twig-extensions-for-rum
    By rande, 2 years ago
  • Fix twig method definition
    By thormeier, 2 years ago
  • Get default licence and appname from php.ini
    By emmanuelvella, 2 years ago
  • Merge pull request #71 from thormeier/twig-extensions-for-rum
    By rande, 2 years ago
  • Introduce Twig extension for BrowserTiming
    By thormeier, 2 years ago
  • Merge pull request #78 from Flagbit/fix-travis
    By rande, 2 years ago
  • Allow dev-master builds to fail
    By davidfuhr, 2 years ago
  • Adds self-update for composer to hopefully fix travis timeout
    By davidfuhr, 2 years ago
  • Merge pull request #73 from mremi/datetime-in-changelog
    By rande, 2 years ago
  • Added date time to the change log
    By mremi, 2 years ago
  • Merge pull request #30 from LExpress/console-exception
    By rande, 2 years ago
  • Merge pull request #1 from rmasters/console-exception
    By GromNaN, 3 years ago
  • Fix method used for ConsoleExceptionEvent on CommandListener
    By rmasters, 3 years ago
  • Add a test for console exception listener
    By rmasters, 3 years ago
  • Merge pull request #68 from mremi/fix-capifony-task
    By rande, 3 years ago
  • Restricted Capifony deployment task to run it only on primary node
    By mremi, 3 years ago
  • Notify NewRelic on command exception
    By GromNaN, 3 years ago
  • Merge pull request #62 from pborreli/patch-1
    By rande, 3 years ago
  • Fixed typos
    By pborreli, 3 years ago
  • add a new tab block
    By Thomas Rabaix, 3 years ago