Class: HoneycombRails::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
# File 'lib/honeycomb-rails/config.rb', line 6

def initialize
  @dataset = 'rails'
  @db_dataset = 'active_record'
  @record_flash = true
  @record_user = :detect
  @logger = Rails.logger
  @capture_exceptions = true
  @capture_exception_backtraces = true
  @sample_rate = 1
end

Instance Attribute Details

#capture_exception_backtracesObject

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



72
73
74
# File 'lib/honeycomb-rails/config.rb', line 72

def capture_exception_backtraces
  @capture_exception_backtraces
end

#capture_exceptionsObject

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



68
69
70
# File 'lib/honeycomb-rails/config.rb', line 68

def capture_exceptions
  @capture_exceptions
end

#datasetObject

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



43
44
45
# File 'lib/honeycomb-rails/config.rb', line 43

def dataset
  @dataset
end

#db_datasetObject

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



47
48
49
# File 'lib/honeycomb-rails/config.rb', line 47

def db_dataset
  @db_dataset
end

#loggerObject

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



26
27
28
# File 'lib/honeycomb-rails/config.rb', line 26

def logger
  @logger
end

#record_flash=(value) ⇒ Object (writeonly)

Whether to record flash messages (default: true).



18
19
20
# File 'lib/honeycomb-rails/config.rb', line 18

def record_flash=(value)
  @record_flash = value
end

#record_userObject

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

  • :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_rateObject

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

Valid values:

  • Integer - sample Honeycomb events at a constant rate

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

  • TODO: :rails - default Rails dynamic sampling?

You can also pass a Proc, which will be called with the ActiveSupport::Notifications payload that was used to populate the Honeycomb event, and which should return a sample rate for the request in question.



64
65
66
# File 'lib/honeycomb-rails/config.rb', line 64

def sample_rate
  @sample_rate
end

#writekeyObject

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



50
51
52
# File 'lib/honeycomb-rails/config.rb', line 50

def writekey
  @writekey
end

Instance Method Details

#record_flash?Boolean

Whether to record flash messages (default: true).

Returns:

  • (Boolean)


20
21
22
# File 'lib/honeycomb-rails/config.rb', line 20

def record_flash?
  !!@record_flash
end