Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Honeycomb support #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ gem 'capistrano-rbenv'
gem 'capistrano3-puma'
gem "loofah", ">= 2.2.3"

# Honeycomb
gem 'sequel'
gem 'honeycomb-beeline'
gem 'rack-honeycomb', '~> 0.5.0'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
class ApplicationController < ActionController::API

if %w[production staging development].include? Rails.env
def append_info_to_payload(payload)
super(payload)
Rack::Honeycomb.add_field(request.env, 'classname', self.class.name)
end
end
end
5 changes: 5 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# This file is used by Rack-based servers to start the application.
#

# Initialize Honeycomb before everything else
require 'honeycomb-beeline'
Honeycomb.init

require_relative 'config/environment'

Expand Down
12 changes: 12 additions & 0 deletions config/initializers/hacks/libhoney.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal:true

Libhoney::LogTransmissionClient.class_eval do
def add(event)
if @verbose
data = "Honeycomb dataset '#{event.dataset}' | #{event.timestamp.iso8601}"
data << " (sample rate: #{event.sample_rate})" if event.sample_rate != 1
@output.print("#{data} | ")
end
@output.puts(event.data.to_s.to_json)
end
end