Heroku Deployment Hook

by Dan Riti on February 27, 2014

heroku

To help understand the correlation between system events and performance trends, TraceView provides the ability to log arbitrary events using it’s Annotations API. In this tutorial, we will demonstrate how we can leverage Heroku’s Deploy Hooks add-on to automatically log deployment annotations in TraceView every time you push new code to Heroku.

NOTE: This tutorial assumes that you are:

To begin, you’re going to need your TraceView Access (API) key. Grab this by navigating to the Organization Overview page (in the TraceView navigation menu: Settings => Overview). Please note that you must be a TraceView administrator to access this page in the application.

Next, let’s navigate to where our Heroku application repository lives on our local file system. For this example we’ll be using MegaURL, a URL amplifier:

$ cd /home/dan/dev/megaurl

From here, we can use the heroku CLI tool to provision the Deploy Hooks add-on:

$ heroku addons:add deployhooks:http \
--url="https://herokuapp1234567.tv.appneta.com/api-v2/log_message\
?key=abcd1234-ab12-ab12-ab12-abcefg123456\
&message=Deploy%20{{head}}\
&username={{user}}"

Some important notes when constructing the --url parameter:

  • Replace herokuapp1234567 with your TraceView subdomain
  • Replace the key value with your TraceView Access key
  • Customize the message value to include more Heroku variables
  • URL encode any whitespace in your message

Now let’s create an empty commit and deploy to Heroku:

$ git commit --allow-empty -m "An empty commit"
$ git push heroku master
Fetching repository, done.
Counting objects: 1, done.
Writing objects: 100% (1/1), 189 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)

-----> Ruby app detected
...
-----> Launching... done, v57
-----> Deploy hooks scheduled, check output in your logs
       http://megaurl.herokuapp.com deployed to Heroku

To git@heroku.com:megaurl.git
   648ade2..beaa724  master -> master

At the end of the log, you can see that Heroku has scheduled the the deploy hook. Thus, deployment annotations will now appear at the top of all your TraceView application performance visualizations:

heroku deploy hook

And just click on the annotation to toggle it:

heroku deploy hook

Looks like the overhead of deployment caused a short increase in server latency, but performance clearly levels out once the new dynos are fully up and running. Thus, I’m able to conclude that my “empty commit” code change has had no negative performance impact on the performance of my application.

Correlating application performance changes with deployments couldn’t be easier.

TwitterFacebookLinkedInRedditEmail

Get the most awesome monitoring for your entire site.

Create your free account of TraceView and AppView today!

Create your free account