Product Updates   Observability   Instrumentation  

Instrument Your Rails Apps Automatically With Honeycomb's New Rails Integration

By Sam Stokes  |   Last modified on January 11, 2019

You’ve always been able to get observability for your Ruby apps by instrumenting them with our SDK, affectionately known as libhoney. Unfortunately, instrumenting code you’ve already written is nobody’s favourite job. If only there were some way to automate the repetitive parts, so you could get instant insight into what your app is doing in production, and then focus your effort on augmenting that insight with the information that’s unique to your app!

gif of mechanical honeycomb press

That’s why we’re releasing our Rails integration. Out of the box, Rails web apps provide a rich stream of data about what they’re doing and how they’re performing. By connecting that stream to Honeycomb, you get the realtime observability, insight, and analytics that you’ve always wanted.

Get the data flowing with just a few clicks

Getting started is easy. Just add gem 'honeycomb-rails' to your app’s Gemfile, and a short config snippet to identify your Honeycomb account:

HoneycombRails.configure do |conf|
  conf.writekey = 'YOUR-HONEYCOMB-WRITEKEY'
end

That’s all you need to instrument your app’s requests and ActiveRecord queries. Now you can start asking questions like:

  • Which controllers and actions are the slowest to return in my app?
  • Which routes spend the most time making database calls? What are the commonalities among the slowest-rendering pages in my app?
  • Which users have seen that “Failed to save” flash error message the most lately? What other errors have they run into?

graph showing count and p95 of controller action durations

Honeycomb lets you ask these questions of your app as it’s running in production. Once you’ve got an answer, you can refine the question: e.g. try filtering to only the most common error, or breaking down by user.

Add your own custom fields for even greater insight

However, the real power of observability comes when you augment your instrumentation with context that’s unique to your app. For example, if your app deals with posts, you might want to understand the performance profile or error distribution associated with displaying a particular post. You can do that by adding fields to the honeycomb_metadata hash in any controller method:

class PostsController < ApplicationController
  # in any controller method
  def show
    @post = Post.find(params[:id])

    # The request event will be augmented with post ID
    honeycomb_metadata[:post_id] = @post.id
    # ...
  end
end

Want observability for your Rails apps? Try out our Rails integration and get started for free.

 

Related Posts

Observability  

Frontend Debugging Is Bad and it Should Feel Bad

There’s a sentence that strikes fear into the heart of every frontend developer I've ever met: Users are reporting issues, and we don't know how...

OpenTelemetry   Instrumentation  

OpenTelemetry Best Practices #2 Agents, Sidecars, Collectors, Coded Instrumentation

For years, we’ve been installing what vendors have referred to as “agents” that reach into our applications and pull out useful telemetry information from them....

Observability   News & Announcements  

Focused Labs & Honeycomb: Better Together

We're excited to unveil a new collaboration with Focused Labs, a leap forward in our shared commitment to advancing modern observability practices and enhancing the...