Sha256: 096ece6273db23dd9012ae4a43cc610ee8b3cd05e34c03723889d3ed862339c2

Contents?: true

Size: 1.71 KB

Versions: 16

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

require "rails/generators"
require "active_support/core_ext/string/strip"

##
# Generates an intializer for configuring the Honeycomb beeline
#
class HoneycombGenerator < Rails::Generators::Base
  source_root File.expand_path("templates", __dir__)

  argument :write_key, required: true, desc: "required"

  class_option :dataset, type: :string, default: "rails"

  gem "honeycomb-beeline"

  desc "Configures honeycomb with your write key"

  def create_initializer_file
    initializer "honeycomb.rb" do
      <<-RUBY.strip_heredoc
        Honeycomb.configure do |config|
          config.write_key = #{write_key.inspect}
          config.dataset = #{options['dataset'].inspect}
          config.presend_hook do |fields|
            if fields["name"] == "redis" && fields.has_key?("redis.command")
              # remove potential PII from the redis command
              if fields["redis.command"].respond_to? :split
                fields["redis.command"] = fields["redis.command"].split.first
              end
            end
            if fields["name"] == "sql.active_record"
              # remove potential PII from the active record events
              fields.delete("sql.active_record.binds")
              fields.delete("sql.active_record.type_casted_binds")
            end
          end
          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
      RUBY
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
honeycomb-beeline-2.8.2 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.8.1 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.8.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.7.1 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.7.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.6.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.5.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.4.2 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.4.1 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.4.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.3.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.2.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.1.2 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.1.1 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.1.0 lib/generators/honeycomb/honeycomb_generator.rb
honeycomb-beeline-2.0.0 lib/generators/honeycomb/honeycomb_generator.rb