As those of you who’ve been following along will know, we’ve been hard at work developing new features for the Agent SDK. Today, we’re excited to announce support for Transaction Traces in the Agent SDK Beta.
To show you what the SDK can do today, we set up and instrumented WordPress running on the HipHop Virtual Machine (hhvm). We used this to demonstrate how to get started using the SDK and immediately have performance data show up in New Relic, including the newly supported transaction traces.
Before getting started, you should read the following articles to set up WordPress and familiarize yourself with hhvm’s Extension API:
Installing the Agent SDK
- Download the Agent SDK
- Copy the library files to /usr/lib or /usr/local/lib
- Copy the header files to /usr/include or /usr/local/include
Building the Agent SDK hhvm extension
- Checkout Agent SDK Samples to get the hhvm example
- Build the extension:
> cd hhvm/extension
> cmake .
This will create a library file named newrelic.so which you will point to when configuring hhvm.
The Agent SDK example ships with a sample hhvm config file called hhvm.hdf. You’ll need to make the following changes to this file:
- Replace NEWRELIC_LICENSE_KEY with your license key under the EnvVariables section
- Set the newrelic path under the DynamicExtensions section to the library that you built in the previous step, e.g.: newrelic = /var/www/newrelic.so
Now that you’ve built the Agent SDK hhvm extension you can begin instrumenting WordPress. Most of the work done inside WordPress goes through a single function that processes actions (actions are events that occur within the lifecycle of a page). This function is called do_action. This provides a logical place for us to add instrumentation, and it will give you a nice breakdown of all the actions that occur for a given transaction.
Inside the Agent SDK examples download, we’ve included a file called wordpress-snippets.php that contains several code snippets with instructions. The instructions will tell you where to paste these code snippets.
All you have to do next is fire up hhvm, navigate the site a bit, and you’ll start to see transactions show up in New Relic.
- Run $HPHP_HOME/hphp/hhvm/hhvm –mode daemon –config /path/to/hhvm.hdf
- Open a browser and navigate to: http://localhost:8888
- Click around on the site to initiate some WordPress actions
- Wait a couple minutes, then log into New Relic
Now you’ll get a good picture of what’s happening in your WordPress site. If your site is really responsive, you probably won’t see a transaction trace. However, since you’re just trying out the SDK, you might want to artificially make a slow page to see a trace show up in New Relic. Here’s what a trace for a WordPress transaction looks like:
For more information about the Agent SDK, see: https://docs.newrelic.com/docs/features/agent-sdk