ekino/EkinoNewRelicBundle — pull request #5 by magnusnordlander (2012-12-03 14:38:28+00:00)
Title: Multiple new features

We've been using this fork in production on our e-commerce platform for a couple of months now, so it's time to contribute back (even though we're sorry it's not in separate feature branches) :)

We fixed a bug causing the wrong application name to be reported to New Relic, and we also implemented a bunch of new features.

Hopefully these features can be as useful to you as they have been to us.

## Configurable transaction naming

Currently, the bundle only allows naming the transactions by route. This PR extends the transaction naming with an additional scheme, by controller, and the ability to implement your own transaction naming scheme.

Any transaction naming scheme should implement ```Ekino\Bundle\NewRelicBundle\TransactionNamingStrategy\TransactionNamingStrategyInterface```. The two default schemes are easily configurable in the bundle configuration, by setting ```transaction_naming``` to either ```route``` or ```controller```.

Any other scheme can be used by setting ```transaction_naming``` to ```service``` and setting ```transaction_naming_service``` to the name of your own transaction naming service.

## Deployment notification

A new command, ```newrelic:notify-deployment``` is introduced 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.

```
Tesla:src magnus$ 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
```

We also include a Capistrano recipe to automate the deployment notifications.

### Implementation note

Currently this command uses just ```file_get_contents``` to do it's thing. We didn't want to introduce a new dependency with this PR, but if you feel that introducing a dependency on e.g. [Buzz](https://github.com/kriswallsmith/Buzz) is not a problem, we'd be happy to update the code to make it nicer.

## Logging

The bundle can now log what interactions are being used communicating with New Relic. To enable, simply set the ```logging``` configuration option to ```true```.

## Fine-grained instrumentation

The default configuration of the New Relic PHP agent is to inject the Auto-RUM-code in every page. We've added an option to give more fine-grained control over which pages are instrumented.

By setting the ```instrument``` configuration option to ```true```, HTML pages will still be instrumented. However, if the request has an ```_instrument``` attribute, and the value of the attribute is ```false```, no instrumentation will occur. Setting this attribute can be done e.g. in the routing configuration.

## Exception logging to New Relic

By default, Symfony2 handles all your exceptions. Sadly, this means that the error rate in New Relic will be off, since it won't receive your exceptions.

By setting the ```log_exceptions``` configuration option to ```true```, your exceptions (unless they implement ```Symfony\Component\HttpKernel\Exception\HttpExceptionInterface```) will be shipped off to New Relic, for your perusal.