class HoneycombRails::Config

Configuration for the Honeycomb Rails integration.

Specify this at app initialization time via {configure}.

Attributes

capture_exception_backtraces[RW]

If set to true, captures backtraces when capturing exception metadata. No-op if capture_exceptions is false. (default: true)

capture_exceptions[RW]

If set to true, captures exception class name / message along with Rails request events. (default: true)

client[RW]

Override the default Libhoney::Client used to send events to Honeycomb. If this is specified, {#writekey} will be ignored. @api private

dataset[RW]

Send request events to the Honeycomb dataset with this name (default: 'rails'). Set to nil or an empty string to disable.

db_dataset[RW]

Send ActiveRecord query events to the Honeycomb dataset with this name (default: 'active_record'). Set to nil or empty string to disable.

logger[RW]

If set, routes HoneycombRails-specific log output to this logger (defaults to Rails.logger)

record_flash[W]

Whether to record flash messages (default: true).

record_user[RW]

If set, determines how to record the current user during request processing (default: :detect). Set to nil or false to disable.

Valid values:

  • :devise - if your app uses Devise for authentication

  • :devise_api - if your app uses Devise for authentication in an 'api' namespace

  • :detect - autodetect how to determine the current user

  • nil, false - disable recording current user

You can also pass a Proc, which will be called with the current controller instance during each request, and which should return a hash of metadata about the current user.

sample_rate[W]

@!attribute sample_rate If set, determines how to record the sample rate for a given Honeycomb event. (default: 1, do not sample)

Valid values:

  • Integer > 1 - sample Honeycomb events at a constant rate

  • 1 - disable sampling on this dataset; capture all events

You can also pass a block, which will be called with the event type and the ActiveSupport::Notifications payload that was used to populate the Honeycomb event, and which should return a sample rate for the request or database query in question. For example, to sample successful (200) requests and read (SELECT) queries at 100:1 and all other requests at 1:1:

@example Dynamic sampling with a block

config.sample_rate do |event_type, payload|
  case event_type
  when 'sql.active_record'
    if payload[:sql] =~ /^SELECT/
      100
    else
      1
    end
  when 'process_action.action_controller'
    if payload[:status] == 200
      100
    else
      1
    end
  end
end
writekey[RW]

The Honeycomb write key for your team (must be specified).

Public Class Methods

new() click to toggle source
# File lib/honeycomb-rails/config.rb, line 6
def initialize
  @dataset = 'rails'
  @db_dataset = 'active_record'
  @record_flash = true
  @record_user = :detect
  @capture_exceptions = true
  @capture_exception_backtraces = true
  @sample_rate = 1
end

Public Instance Methods

record_flash?() click to toggle source

Whether to record flash messages (default: true).

# File lib/honeycomb-rails/config.rb, line 19
def record_flash?
  !!@record_flash
end
sample_rate(&block) click to toggle source
# File lib/honeycomb-rails/config.rb, line 92
def sample_rate(&block)
  if block
    self.sample_rate = block
  else
    @sample_rate
  end
end