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

Software Engineering   Observability  

Navigating Software Engineering Complexity With Observability

In the not-too-distant past, building software was relatively straightforward. The simplicity of LAMP stacks, Rails, and other well-defined web frameworks provided a stable foundation. Issues...

Observability   News & Announcements  

Announcing Honeycomb Support Business Hours in Europe

Earlier this year, Honeycomb announced the launch of data residency in Europe. To meet the growing needs of our customers in the region, we are...

Observability   Metrics  

The Cost Crisis in Metrics Tooling

In my February 2024 piece The Cost Crisis in Observability Tooling, I explained why the cost of tools built atop the three pillars of metrics,...