diff --git a/Envfile b/Envfile index bcddf4ad4..af48c4689 100644 --- a/Envfile +++ b/Envfile @@ -117,8 +117,8 @@ variable :FASTLY_API_KEY, :String, default: "Optional" variable :FASTLY_SERVICE_ID, :String, default: "Optional" # Honeycomb for monitoring and observability -# https://www.honeycomb.io/ -variable :HONEYCOMB_API_KEY, :String, default: "Optional" +# (https://www.honeycomb.io/) +variable :HONEYCOMB_API_KEY, :String, default: "" # Google analytic # (https://developers.google.com/analytics/devguides/reporting/core/v4) diff --git a/Gemfile b/Gemfile index 7d99d7623..247203634 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,7 @@ gem "inline_svg", "~> 1.5" # Embed SVG documents in your Rails views and style t gem "jbuilder", "~> 2.9" # Create JSON structures via a Builder-style DSL gem "jquery-rails", "~> 4.3" # A gem to automate using jQuery with Rails gem "kaminari", "~> 1.1" # A Scope & Engine based, clean, powerful, customizable and sophisticated paginator +gem "libhoney", "~> 1.14" # Ruby gem for sending data to Honeycomb gem "liquid", "~> 4.0" # A secure, non-evaling end user template engine with aesthetic markup gem "nokogiri", "~> 1.10" # HTML, XML, SAX, and Reader parser gem "octokit", "~> 4.14" # Simple wrapper for the GitHub API diff --git a/Gemfile.lock b/Gemfile.lock index 1b2826542..6173899a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -930,6 +930,7 @@ DEPENDENCIES jquery-rails (~> 4.3) kaminari (~> 1.1) launchy (~> 2.4) + libhoney (~> 1.14) liquid (~> 4.0) memory_profiler (~> 0.9) nakayoshi_fork (~> 0.0.4) diff --git a/config/initializers/honeycomb.rb b/config/initializers/honeycomb.rb new file mode 100644 index 000000000..4a4a46a8c --- /dev/null +++ b/config/initializers/honeycomb.rb @@ -0,0 +1,28 @@ +if Rails.env.test? + Honeycomb.configure do |config| + config.client = Libhoney::TestClient.new + end + + HoneycombClient = Libhoney::TestClient.new +else + honeycomb_api_key = ApplicationConfig["HONEYCOMB_API_KEY"] + + # Honeycomb automatic Rails integration + Honeycomb.configure do |config| + config.write_key = honeycomb_api_key + config.dataset = "rails" + config.notification_events = %w[ + sql.active_record + render_template.action_view + render_partial.action_view + render_collection.action_view + process_action.action_controller + send_file.action_controller + send_data.action_controller + deliver.action_mailer + ].freeze + end + + # here we create an additional Honeycomb client that can be used to send custom events + HoneycombClient = Libhoney::Client.new(writekey: honeycomb_api_key, dataset: "dev-ruby") +end diff --git a/config/initializers/honeycomb_event_client.rb b/config/initializers/honeycomb_event_client.rb deleted file mode 100644 index 03c45222d..000000000 --- a/config/initializers/honeycomb_event_client.rb +++ /dev/null @@ -1 +0,0 @@ -HoneycombClient = Libhoney::Client.new(writekey: ENV["HONEYCOMB_API_KEY"], dataset: 'dev-ruby') diff --git a/config/initializers/honeycomb_rails.rb b/config/initializers/honeycomb_rails.rb deleted file mode 100644 index 722a2ccce..000000000 --- a/config/initializers/honeycomb_rails.rb +++ /dev/null @@ -1,14 +0,0 @@ -Honeycomb.configure do |config| - config.write_key = ENV["HONEYCOMB_API_KEY"] - config.dataset = "rails" - config.notification_events = %w[ - sql.active_record - render_template.action_view - render_partial.action_view - render_collection.action_view - process_action.action_controller - send_file.action_controller - send_data.action_controller - deliver.action_mailer - ].freeze -end