Redis, Resque, MongoDB and more, Custom Instrumentation in RPM, Part 1

Do you use Camping, Paperclip, MongoDB (via MongoMapper or Mongoid), Resque or Redis? You can get performance metrics in RPM for all of these frameworks right now just by installing the rpm_contrib gem!

The rpm_contrib gem contains custom instrumentation generously written and shared by expert RPM users.

Why add custom instrumentation?

Inside every application we find a unique ecosystem of custom code, libraries and subsystems that work together to bring us a cohesive user experience.  To get a better picture of our application performance, we need visibility into every critical aspect of our architecture.  If only there was a way to instrument those other components in RPM…

Can we instrument custom code with RPM?  Yes we can! For Ruby or Java, it’s really simple to get all the great performance metrics you’ve come to love by just adding a line or two to your code.

How rpm_contrib Makes RPM Even More Awesome

Camping, is a web framework, written in Ruby, which consistently stays at less than 4kB of code. Adding the rpm_contrib gem to your Camping app, you’ll get much of the same controller-level instrumentation in RPM as you get with Rails.

Paperclip is a file attachment plugin for Ruby on Rails’ Active Record classes which turns files into attributes that work the same way as normal database fields. The instrumentation for Paperclip includes metrics on the attachments themselves along with the storage mechanism, either on a local file system or S3. With RPM Gold, you can create custom views to surface these metrics and display them alongside any other graph of metrics in your app.

MongoDB is being talked about and used all over the place. It bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality). If you’re using MongoMapper or Mongoid you’ll see all your Mongo queries and interactions show up in the database tab of RPM.

Resque is a Redis-backed Ruby library for creating background jobs, placing those jobs on multiple queues, and processing them later. Like the support for Delayed Job that ships with the RPM Ruby agent, with rpm_contrib, Resque jobs will show up in the Background Tasks tab in RPM.

Redis is simply awesome. It’s an insanely fast, networked, in-memory, persistent, journaled, key-value data store. We turn to Redis for performance, so shouldn’t we be monitoring it too? With the rpm_contrib gem installed you’ll see your Redis interactions show up under the Database tab in RPM.

Have Custom Instrumentation to Share?

The rpm_contrib gem, like the rpm ruby agent itself, is hosted on github.  To contribute to the gem, just fork the project on github, add the instrumentation for the library you need and send a pull request.  Making your contribution on a topic branch and not changing the Rakefile, version or changelog makes it really easy for us to accept your changes and get your code released to the world that much faster.

Next Up

Custom instrumentation in RPM is pretty awesome. Far too awesome for just one post. Here’s what’s coming up next:

  • A how-to guide on writing custom instrumentation in Ruby, featuring a very popular gem
  • Writing custom dashboards in RPM that can display any metric collected from your app
  • A how-to guide on writing custom instrumentation in Java
brian@emphaticsolutions.com'

Marketing at Github View posts by .

Interested in writing for New Relic Blog? Send us a pitch!