Product Updates   Observability   Instrumentation   Connectors & Integrations  

Instrument Your Ruby App In Minutes with the Honeycomb Beeline for Ruby

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, but we know 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!

there has to be a better way! fake infomercial gif

 

Meet the Honeycomb Beeline for Ruby. Like our Beelines for Go and Node, it understands the common packages you're using and automatically instruments them to send useful events to Honeycomb. Then once you've got a chance to explore your app's behavior, you can add custom fields specific to your app with just one line of code.

What you'll need

  • A Ruby web app of your choice
  • Ruby 2.2+
  • A Honeycomb API key, found on your Honeycomb Account page. (Sign up for free if you haven't already!)

Setup

First add the Beeline to your Gemfile:

gem 'honeycomb-beeline'

Then call Honeycomb.init in your app's startup script (e.g. config.ru):

require 'honeycomb-beeline'
Honeycomb.init(writekey: 'abcabc123123defdef456456', dataset: 'myapp')

That's all you need for most web apps! The Beeline will automatically instrument your incoming HTTP requests, outbound requests, and database queries, and send events to Honeycomb. Check out the docs for more information on what's supported, and some example queries to try.

Explore!

Now that your app is instrumented, let's take a look at your data.

Log into Honeycomb. You should see a new myapp dataset waiting on your team homepage - let's open it and find out which endpoints were hit most often.

In the sidebar on the right, you'll see the schema from events that the Ruby Beeline has automatically sent into Honeycomb. Let's take a look at the data that was generated from your HTTP requests.

screenshot of schema in sidebar

These look promising. Let's break down by request.method and request.path to get an overview of our app endpoints, and calculate the COUNT to find out how many times each endpoint was used.

screenshot of Query Builder

That's all you need to start visualizing and investigating your app behavior in Honeycomb! Learn more here about exploring your data and constructing queries in Honeycomb.

screenshot of query result graph

Customize

The real power of observability comes when you augment your instrumentation with context that's unique to your app. For example, let's say you'd like to deprecate an endpoint, and you want to know which users are using it. In your handler for that endpoint, you can add a custom field onto the event associated with the request:

Rack::Honeycomb.add_field(env, :user_id, current_user.id)

Enjoy!

Check out the Beeline documentation for more information on what else is supported.

Haven't tried Honeycomb before? Sign up for free!

 

Related Posts

OpenTelemetry   Observability  

What Is a Telemetry Pipeline?

In a simple deployment, an application will emit spans, metrics, and logs which will be sent to api.honeycomb.io and show up in charts. This works...

Software Engineering   Observability  

5 Ways Honeycomb Saves Time, Money, and Sanity

If debugging has sucked the soul out of your engineers, we’ve got the answer: event-based observability. Instead of spending hours and resources trying to find...

Product Updates  

Feature Focus: April 2023

You know the old saying, I’m sure: “April deploys bring May joys.” Okay, maybe it doesn’t go exactly like that, but after reading what we’ve...