Honeycomb in Rails with separate dev and production events

Honeycomb made it suuuuuper easy to see traces of HTTP requests hitting my app. Right from my computer! We installed one gem, did one rails generate from a cut-and-paste their dataset creation page gave me. Start up rails server, hit http://localhost:3000, and boom! A thing on a graph in Honeycomb!

a single request shows up in Honeycomb

That was cool. Except, um, I’m on my local machine. I wanted this dataset to be for production.

Their guidance on this doesn’t make complete sense to me, but it does say that we should separate dev and production events into separate datasets.

In Honeycomb, we created a second dataset with a “-dev” suffix. Then we changed our Honeycomb configuration in config/initializers/honeycomb.rb.


Honeycomb.configure do |config|
  config.write_key = 'YOUR_API_KEY'
  config.dataset = "mydataset"
  ... bunch of sensible stuff ...


Honeycomb.configure do |config|
  config.write_key = 'OK I DIDN"T REALLY PUT MY API KEY HERE'
  config.dataset = Rails.env.production? ? "mydataset" : "mydataset-dev"
  ... bunch of sensible stuff ...

That’s it! The write_key is the same for both. Only the name of the dataset changed. Rails makes it easy to tell whether you’re in production; that’s part of its slick-for-development, useful-for-prod out-of-the-boxness.

Avdi points out that it’s better to default to the dev dataset than the production one. Environments we haven’t explicitly handled (like test) can dump their events into the dev dataset without polluting prod.

As you may notice, I don’t recommend hard-coding your API key. Here’s what we did instead.

Keep your eyes on production.

As a developer, I don’t just implement features in code. I operate capabilities in running software. That means that I don’t get stuff running on my box and forget about it. I’m mindful of where the data belongs.

Observable code is secure code, because traceability is part of security. It’s my job to understand and show what the software is doing.

Being able to see into my app makes my job easier all around!

I’m super excited to have Honeycomb hooked up. Poof, traces of all http requests. Poof, the SQL that’s running inside each one and how slow it is. Poof, Jess, talk about that in another post.