Instrumentation   Product Updates  

New features for Ruby and Rails applications with a new version of the Honeycomb Beeline for Ruby

By Martin Holman  |   Last modified on July 26, 2019

We are excited to announce a new version of the Honeycomb Beeline for Ruby!

This new version solidifies our Ruby support, providing out-of-the-box automatic instrumentation for additional frameworks and enhanced support for our currently supported frameworks. The goods:

  • Support for more rails versions 4.1-6
  • Presend/sample hooks
  • Rake integration
  • Active support integration
  • Warden/Devise integration
  • Trace fields
  • Rollup fields
  • More ergonomic API
  • Add fields to current span more easily
  • Support for non rack based applications
  • Trace aware deterministic sampling
  • Reduces/eliminates incompatibility issues with various gems

What you'll need

  • Ruby 2.2 or greater
  • A Honeycomb API key, found on your Honeycomb Team Settings page. (Sign up for free if you haven’t already!)

Set up the configuration

For Rails applications we now have a generator that creates  a configuration file for the Beeline.

bundle exec rails generate honeycomb YOUR_API_KEY --dataset rails

This generates a configuration file in config/initializers/honeycomb.rb with the Beeline pre-configured for your Rails application:

Honeycomb.configure do |config|
  config.write_key = "{YOUR_API_KEY}"
  config.dataset = "rails"
  config.notification_events = %w[

Instrument your app with relevant context

With the basic setup complete you will start seeing events and traces in your Honeycomb dashboard. From here,  you can start adding context to your events by adding custom fields to spans, and adding additional child spans to your traces:

def slow_operation
  Honeycomb.start_span(name: "slow_operation") do |span|
    # ... go on and do the slow opp, add more data along the way
    span.add_field("interesting_thing", "banana")

Any additional child spans you add this way will join the trace which is started by the web requests connecting  to your rails application.

Scrub data you don't want sent

Once you start instrumenting additional areas of your application, you might find there is information in your events that you wish to remove or scrub so that you don't send sensitive information to Honeycomb. For this purpose, we have added a presend_hook that allows you to manipulate any of the information that your application is generating before it is sent to Honeycomb:

Honeycomb.configure do |config|
  config.write_key = "{YOUR_API_KEY}"
  config.dataset = "rails"
  config.presend_hook do |fields|
    if fields.has_key? "app.credit_card_number"
      fields["app.credit_card_number"] = "[REDACTED]"

Sample your data to focus on what matters

Now that you have more events being sent to Honeycomb, you may want to explore the world of sampling. To help you with that, we have made the Ruby Beeline deterministic sampling "trace" aware so that the whole trace is now sampled (or not), allowing you to always see the complete trace in your Honeycomb dashboard.

To allow you to customize further, we added a sample_hook. In the following example we use this new hook to perform dynamic sampling using the app.response_code field on the events:

class CustomSampler
  extend Honeycomb::DeterministicSampler

  def self.sample(fields)
    case fields["app.response_code"]
    when 200
      rate = 100
      [should_sample(rate, fields["trace.trace_id"]), rate]
      [true, 1]

Honeycomb.configure do |config|
  config.write_key = "{YOUR_API_KEY}"
  config.dataset = "rails"
  config.sample_hook do |fields|

Want to go further?

If you want to customize your Beeline further, you can find the docs here.

Get started with automatic instrumentation for your language: check out our Beelines and sign up for a free trial!


Related Posts

Product Updates  

Announcing New CircleCI + Honeycomb Integration Guide

If you’re writing software today, then you likely use a CI/CD pipeline to build and test your code before deploying it to production. Having a...

Product Updates  

Feature Focus: October 2022

In our Feature Focus October 2022, we've updated documentation and derived columns, provided guides to make CI/CD easier, and more....

News & Announcements   Product Updates  

Introducing Honeycomb Service Map: A Dynamic, Interactive, and Actionable View of Your Entire Environment

Today, we're announcing the launch of Honeycomb Service Map. This isn't your grandparent's version of a service map. This feature reimagines what it is that...