Class: HoneycombGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/honeycomb/honeycomb_generator.rb

Overview

Generates an intializer for configuring the Honeycomb beeline

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/honeycomb/honeycomb_generator.rb', line 20

def create_initializer_file
  initializer "honeycomb.rb" do
    <<-RUBY.strip_heredoc
      Honeycomb.configure do |config|
        config.write_key = #{write_key.inspect}
        config.service_name = #{options['service_name'].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