Class: HoneycombRails::Config
- Inherits:
-
Object
- Object
- HoneycombRails::Config
- Defined in:
- lib/honeycomb-rails/config.rb
Overview
Configuration for the Honeycomb Rails integration.
Specify this at app initialization time via configure.
Instance Attribute Summary collapse
-
#capture_exception_backtraces ⇒ Object
If set to true, captures backtraces when capturing exception metadata.
-
#capture_exceptions ⇒ Object
If set to true, captures exception class name / message along with Rails request events.
-
#client ⇒ Object
private
Override the default Libhoney::Client used to send events to Honeycomb.
-
#dataset ⇒ Object
Send request events to the Honeycomb dataset with this name (default: ‘rails’).
-
#db_dataset ⇒ Object
Send ActiveRecord query events to the Honeycomb dataset with this name (default: ‘active_record’).
-
#logger ⇒ Object
If set, routes HoneycombRails-specific log output to this logger (defaults to Rails.logger).
-
#record_flash ⇒ Object
writeonly
Whether to record flash messages (default: true).
-
#record_user ⇒ Object
If set, determines how to record the current user during request processing (default: :detect).
-
#sample_rate(&block) ⇒ Object
If set, determines how to record the sample rate for a given Honeycomb event.
-
#writekey ⇒ Object
The Honeycomb write key for your team (must be specified).
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#record_flash? ⇒ Boolean
Whether to record flash messages (default: true).
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#capture_exception_backtraces ⇒ Object
If set to true, captures backtraces when capturing exception metadata. No-op if capture_exceptions is false. (default: true)
106 107 108 |
# File 'lib/honeycomb-rails/config.rb', line 106 def capture_exception_backtraces @capture_exception_backtraces end |
#capture_exceptions ⇒ Object
If set to true, captures exception class name / message along with Rails request events. (default: true)
102 103 104 |
# File 'lib/honeycomb-rails/config.rb', line 102 def capture_exceptions @capture_exceptions end |
#client ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override the default Libhoney::Client used to send events to Honeycomb. If this is specified, #writekey will be ignored.
44 45 46 |
# File 'lib/honeycomb-rails/config.rb', line 44 def client @client end |
#dataset ⇒ Object
Send request events to the Honeycomb dataset with this name (default: ‘rails’). Set to nil or an empty string to disable.
48 49 50 |
# File 'lib/honeycomb-rails/config.rb', line 48 def dataset @dataset end |
#db_dataset ⇒ Object
Send ActiveRecord query events to the Honeycomb dataset with this name (default: ‘active_record’). Set to nil or empty string to disable.
52 53 54 |
# File 'lib/honeycomb-rails/config.rb', line 52 def db_dataset @db_dataset end |
#logger ⇒ Object
If set, routes HoneycombRails-specific log output to this logger (defaults to Rails.logger)
25 26 27 |
# File 'lib/honeycomb-rails/config.rb', line 25 def logger @logger end |
#record_flash=(value) ⇒ Object (writeonly)
Whether to record flash messages (default: true).
17 18 19 |
# File 'lib/honeycomb-rails/config.rb', line 17 def record_flash=(value) @record_flash = value end |
#record_user ⇒ Object
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.
39 40 41 |
# File 'lib/honeycomb-rails/config.rb', line 39 def record_user @record_user end |
#sample_rate(&block) ⇒ Object
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:
90 |
# File 'lib/honeycomb-rails/config.rb', line 90 attr_writer :sample_rate |
#writekey ⇒ Object
The Honeycomb write key for your team (must be specified).
55 56 57 |
# File 'lib/honeycomb-rails/config.rb', line 55 def writekey @writekey end |
Instance Method Details
#record_flash? ⇒ Boolean
Whether to record flash messages (default: true).
19 20 21 |
# File 'lib/honeycomb-rails/config.rb', line 19 def record_flash? !!@record_flash end |