class HoneycombRails::Config
Configuration for the Honeycomb Rails integration.
Specify this at app initialization time via {configure}.
Attributes
If set to true, captures backtraces when capturing exception metadata. No-op if capture_exceptions
is false. (default: true)
If set to true, captures exception class name / message along with Rails request events. (default: true)
Override the default Libhoney::Client used to send events to Honeycomb. If this is specified, {#writekey} will be ignored. @api private
Send request events to the Honeycomb dataset with this name (default: 'rails'). Set to nil or an empty string to disable.
Send ActiveRecord query events to the Honeycomb dataset with this name (default: 'active_record'). Set to nil or empty string to disable.
If set, routes HoneycombRails-specific log output to this logger (defaults to Rails.logger)
Whether to record flash messages (default: true).
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.
@!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
The Honeycomb write key for your team (must be specified).
Public Class Methods
# 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
Whether to record flash messages (default: true).
# File lib/honeycomb-rails/config.rb, line 19 def record_flash? !!@record_flash end
# File lib/honeycomb-rails/config.rb, line 92 def sample_rate(&block) if block self.sample_rate = block else @sample_rate end end