New Relic Labeling with Quicksilver

Automatically Label Code Changes in New Relic Performance Monitoring using Quicksilver Hooks.

Contributors: Scott Massey.

Discuss in our Forum Discuss in Slack

New Relic® Performance Monitoring is a powerful tool for monitoring the performance of a WordPress or Drupal site. It provides insight into how efficiently a website is using resources, and where improvements can be made in the application. Pantheon offers New Relic® Pro within the Site Dashboard on all sites (excluding Basic) for free.

In this guide, we'll automatically label code changes to your site in New Relic®'s Deployment page using Pantheon's Quicksilver hooks and Terminus. This creates a traceable connection between performance changes and code deployments, allowing developers to determine whether a code change positively or negatively impacted performance.

Configure Quicksilver Hook to Record Deployments

  1. Follow the instructions to activate New Relic® APM Pro if you have not already activated it.

  2. Use Pantheon's Quicksilver hooks to run our example New Relic® script immediately after code is synced on Dev or a Multidev environment and after code is deployed to Test and Live. The script configured in this guide applies a label to the Deployment page in New Relic®.

     Variables

    This process uses Terminus commands that require your site name. Before you begin, set the variable $site in your terminal session to match your site name:

    export site=yoursitename
  3. Clone your Pantheon site repository if you haven't done so already.

  4. Navigate to the project's root directory. You can use Terminus to provide the clone command:

    terminus connection:info $site.dev --fields='Git Command' --format=string
    
    git clone ssh://codeserver.dev.2187...d85b@codeserver.dev.2187...d85b.drush.in:2222/~/repository.git sitename
  5. Copy and run the output command and then change directory to the site code root:

    cd $site
  6. Set the connection mode to Git:

    terminus connection:set $site.dev git
  7. Create a copy of Pantheon's new_relic_deploy.php script in the project's private path:

    mkdir -p private/scripts
    curl https://raw.githubusercontent.com/pantheon-systems/quicksilver-examples/master/new_relic_deploy/new_relic_deploy.php --output ./private/scripts/new_relic_deploy.php
  8. Create a pantheon.yml file if one doesn't already exist in your root directory.

  9. Paste the following workflow into your pantheon.yml file to hook into the platform after code is synced on Dev/Multidev and deployed to Test/Live to fire off the New Relic® integration script:

    pantheon.yml
    api_version: 1
    
    workflows:
      # Log to New Relic when deploying to test or live.
      deploy:
        after:
          - type: webphp
            description: Log to New Relic
            script: private/scripts/new_relic_deploy.php
      # Also log sync_code so you can track new code going into dev/multidev.
      sync_code:
        after:
          - type: webphp
            description: Log to New Relic
            script: private/scripts/new_relic_deploy.php

     Note

    api_version should be set once in pantheon.yml. If you have an existing pantheon.yml with this line, do not add it again.

  10. Add, commit, and push changes to the Dev/Multidev environment:

    git add private/scripts/new_relic_deploy.php
    git commit -am "Adding deployment recording to New Relic"
    git push origin master

    In the terminal, you should see that your pantheon.yml file is being applied. Even this initial code push should appear in your Dev environment's New Relic® account, on the Deployments tab:

    Deployment tab display

  11. Confirm that there are no issues, then deploy your new commit to Test and Live. Your deploys will now be recorded in New Relic® Performance Monitoring.

More Quicksilver Examples

The steps above provide a fast way to integrate New Relic® Performance Monitoring and Pantheon with Quicksilver. The Quicksilver Examples repository provides many more ways to automate development, so please take advantage of them and extend them to fit your workflow.

More Resources