Oink + Request Log Analyzer = Rails Monitoring in one report

If you’ve ever had to track down a memory leak in a Rails application (and who hasn’t forgotten to use will_paginate occasionally), you’re probably already familiar with the excellent Oink plugin by Noah Davis. Oink spits out the actions that are leaking the most.

Oink is a huge help when tracking down a memory leak. However, it doesn’t overcome my laziness. Tracking memory usage is extremely important – talk to any dedicated Rails host and they’ll tell you memory leaks are behind many crashed servers. To make monitoring memory usage less involoved, I needed 3 additions to Oink.

  1. Incremental Analysis. I wasn’t looking forward to setting up a Cron job that emails me the Oink report. It would sit outside our other performance data and be ignored.
  2. Alerts on large leaks. The Oink report output gives a great summary of leaking actions, but when a large leak occurs, I’d like to find out quickly, way before the server starts to run out of memory. Often times a memory leak can be tied to dynamic content – it may leak with some URL parameters but not others.
  3. Integration with throughput & request time monitoring. I already use Request Log Analyzer (RLA) with Scout to monitor throughput and request times – it’d be great to have memory tracking in the same place.

Adding Oink-formatted log parsing to Request Log Analyzer ended up being the Aspirin for my memory headache. The smart guys at Rails Doctors helped me add the Oink format to RLA.

Using Oink with Request Log Analyzer

Just follow steps 1-4 here.

To generate a report:

request-log-analyzer log/production.log --format oink

Sales pitch – incremental analysis & alerts with Scout

So with RLA, I’ve got all of my Rails monitoring metrics in one report. However, I need incremental analysis and alerts on large leaks. I want to catch a large leak before it brings down a server. For that, I’ll use Scout.

Using Oink with Scout is easy – just follow the steps here. It’s the same steps for using Oink+RLA outside of Scout, with an additional step for updating/installing your Scout plugin.

By default, you’ll get an alert when a request results in a memory increase of 50 MB. You can change this threshold in the plugin settings.

The summary memory data is automatically added to your daily Rails performance report.

Scout comes with a free 30 day trial, so you take it for a spin and see if it meets your needs. View our pricing information here.


If you run into any issues we want to hear about it. You can email us at support@scoutapm.com or just submit a support request within Scout.