Enabling New Relic on per-app basis for PHP

There’s nothing revolutionary or earth-shattering in this post, it’s just an aide-mémoire for myself.

Metrics are good, right?


I’ve been using New Relic for a while to get an insight into some of my applications, and in the spirit of “measure all things” I also hooked it up for this site as well.

Despite Django being my go-to framework, and liking Jekyll for static sites, when I needed to update a simple site for an organisation I’m involved with, I opted for WordPress again. Why? Other, non-technical users were going to be responsible for the content, and WordPress makes stuff like this so easy.

Since I was going for quick’n’easy, I also hosted this new site on the same DigitalOcean droplet I have a couple of other small sites on. However it was already hosting another WordPress site, connected to NewRelic and I wanted to separate the applications – I didn’t want all the data going into one bucket!

Turns out this is really trivial to do if you are using Apache VirtualHosts:

<IfModule php5_module>
  php_value newrelic.appname "My Amazing App"

If you want to turn off reporting on a per-VirtualHost basis, this is easy too:

<IfModule php5_module>
  php_flag newrelic.enabled off

HP Chromebook 14 + DigitalOcean (and Ubuntu) = Productivity

Although I still use my desktop replacement (i.e., little-to-no battery life) for a good chunk of my work, recent additions to my setup have resulted in some improvements that I thought others might be interested in.

For Christmas just gone my wonderful wife Suzanne – and my equally wonderful children, but let’s face it was her money not theirs! – bought me a HP Chromebook 14. Since the Chromebooks were first announced, I was dismissive of them, thinking that at best they would be a cheap laptop to install Ubuntu on. However over the last year my attitudes had changed, and I came to realise that at least 70% of my time is spent in some browser or other, and of the other 30% most is spent in a terminal or Sublime Text. This realisation, combined with the improvements Intel Haswell brought to battery life made me reconsider my position and start seriously looking at a Chromebook as a 2nd machine for the couch/coffee shop/travel.

I initially focussed on the HP Chromebook 11 and while the ARM architecture didn’t put me off, the 2GB RAM did. When I found the Chromebook 14 with a larger screen, 4GB RAM and Haswell chipset, I dropped enough subtle hints and Suzanne got the message. 🙂

So Christmas Day came and I finally got my hands on it! First impressions were very favourable: this neither looks nor feels like a £249 device. ChromeOS was exactly what I was expecting, and generally gets out of my way. The keyboard is superb, and I would compare it in quality to that of my late MacBook Pro. Battery life is equally superb, and I’m easily getting 8+ hours at a time.

Chrome – and ChromeOS – is not without limitations though, and although a new breed of in-browser environments such as Codebox, Koding, Nitrous.io, and Cloud9 are giving more options for developers, what I really want is a terminal. Enter Secure Shell from Google – SSH in your browser (with public key authentication). This lets me connect to any box of my choosing, and although I could have just connected back to my desk-bound laptop, I would still be limited to my barely-deserves-the-name-broadband ADSL connection.

So, with my Chromebook and SSH client in place, DigitalOcean was my next port of call, using their painless web interface to create an Ubuntu-based droplet. Command Line Interfaces are incredibly powerful, and despite claims to the contrary most developers spending most of their time with them1. There are a plethora of tools to improve your productivity, and my three must-haves are:

With this droplet I can do pretty much anything I need that ChromeOS doesn’t provide, and connect through to the many other droplets, linodes, EC2 nodes, OpenStack nodes and other servers I use personally and professionally.

In some other posts I’ll expand on how I use (and – equally importantly – how I secure) my DigitalOcean droplets, and which “apps” I use with Chrome.

  1. The fact that I now spend most of my time in the browser and not on the command-line shows you that I’ve settled into my role as an engineering manager! 🙂