Instrument Your Ruby App In Minutes with the Honeycomb Beeline for RubyBy 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!
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!)
First add the Beeline to your Gemfile:
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.
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.
These look promising. Let's break down by
request.path to get an overview of our app endpoints, and calculate the
COUNT to find out how many times each endpoint was used.
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.
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)
Check out the Beeline documentation for more information on what else is supported.
Haven't tried Honeycomb before? Sign up for free!
Software systems are increasingly complex. Applications can no longer simply be understood by examining their source code or relying on traditional monitoring methods. The interplay...