Easy app metrics with Pup

This was originally posted on datadoghq.com by Vivek Patel (2012 hackNY Fellow).This is a guest-post from Vivek Patel, who joined Datadog as a HackNY fellow this summer. College students wondering about their options next summer may want to read this article as well.

Why pup?

One of my main fears as a developer is users complaining about slow page loads. Loading times directly affect both user experience and my bottom line, so I need a way to dig into the performance of my application to address this issue.What are my options?I can tail logs, but logs suck. The pile of numbers and text provide limited context and insight. Logs are more useful to identify errors. But in raw form, they’re impractical to observe the performance of my application. I need to spend time upfront to set log post-processing up and adding and extracting new metrics to and from logs quickly becomes a pain.If only I had easy-to-use, free performance monitoring that gives me actionable graphs in 2 minutes…That’s where Pup comes in.

Getting started

 PupPup is fully open-source. To install it, type this at the command-line:

$ sh -c "$(curl -L http://dtdg.co/setup-pup)" 

Then navigate to http://localhost:17125 and bam! Within seconds, you will see metrics streaming in real time.

Pup is designed for application metrics:

In addition to collecting system metrics, Pup faithfully collects and displays custom metrics. To do so it harnesses the power of StatsD, a metrics collector developed by Etsy. Pup comes with StatsD built-in; no need to reinvent the wheel.To send custom metrics to Pup, you can use the dogstatsd library, which as you will see requires a grand total of 3 lines of code to instrument application code. This library comes in a number of flavors (python, ruby, php, etc.)Here’s an example Ruby web application using Sinatra. First, we need to install the dogstatsd library:

# For ruby librarygem install dogstatsd-ruby# For python library, either:# Install in system python ...sudo easy_install dogstatsd-python# .. or into a virtual enveasy_install  dogstatsd_python

 Now to add Pup instrumentation:

require 'sinatra'require 'statsd'statsd = Statsd.new()get '/' dostatsd.time('pup.render_time') doerb: indexendend

 And you’re done. As soon as the page is hit, you’ll see something like this in Pup:pup render timeThat’s it! If you use Datadog, the first period creates a namespace to organize metrics under.Here’s a 1 minute screencast summarizing the whole process:[vimeo 46778037]

Looking for more?

More thorough documentation on using DogstatsD can be found on api.datadoghq.com.To correlate metrics and events across your infrastructure, give Datadog a spin. It only takes a few minutes to get started.

Previous
Previous

Special thanks to our Fall 2012 hackNY student hackathon judges!

Next
Next

Become a Fall 2012 hackNY Student Hackathon Sponsor!