Class: Koderift::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/koderift/rails/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/koderift/rails/configuration.rb', line 41

def initialize
  @project_token     = nil
  @current_user      = default_current_user
  @filter_params     = %w[
    password password_confirmation
    token secret authenticity_token
    credit_card cvv ssn
  ]
  @max_breadcrumbs            = 20
  @external_call_ignore_hosts = []
  @enabled                    = true
  @rum_enabled                = true
  @rum_sampling_rate          = 0.1
  @slow_job_threshold_ms      = 30_000
end

Instance Attribute Details

#current_userObject

Lambda called with the controller instance to get the current user. Default tries common patterns. Override if your app is different. Example: ->(controller) { controller.current_user }



13
14
15
# File 'lib/koderift/rails/configuration.rb', line 13

def current_user
  @current_user
end

#enabledObject

Whether to enable the instrumentation. Set to false to disable without removing the gem.



27
28
29
# File 'lib/koderift/rails/configuration.rb', line 27

def enabled
  @enabled
end

#external_call_ignore_hostsObject

Hosts to exclude from external call tracking (e.g. internal services, localhost, known noise). Always excludes 127.0.0.1 and localhost.



23
24
25
# File 'lib/koderift/rails/configuration.rb', line 23

def external_call_ignore_hosts
  @external_call_ignore_hosts
end

#filter_paramsObject

Parameters to filter from captured request params.



16
17
18
# File 'lib/koderift/rails/configuration.rb', line 16

def filter_params
  @filter_params
end

#max_breadcrumbsObject

Maximum number of breadcrumbs to capture per request.



19
20
21
# File 'lib/koderift/rails/configuration.rb', line 19

def max_breadcrumbs
  @max_breadcrumbs
end

#project_tokenObject

Required: identifies which project this app reports to. Set from an environment variable in the initializer.



8
9
10
# File 'lib/koderift/rails/configuration.rb', line 8

def project_token
  @project_token
end

#rum_enabledObject

Whether to enable Browser RUM. Set to false for API-only apps. Defaults to true — the meta tag is harmless if rum.js is not loaded.



31
32
33
# File 'lib/koderift/rails/configuration.rb', line 31

def rum_enabled
  @rum_enabled
end

#rum_sampling_rateObject

Fraction of sessions to capture (0.0–1.0). Default 0.1 (10%). Passed to rum.js so sampling happens client-side.



35
36
37
# File 'lib/koderift/rails/configuration.rb', line 35

def rum_sampling_rate
  @rum_sampling_rate
end

#slow_job_threshold_msObject

Threshold in milliseconds above which a Sidekiq job is marked 'slow' in the emitted log payload. Default 30_000 (30 seconds).



39
40
41
# File 'lib/koderift/rails/configuration.rb', line 39

def slow_job_threshold_ms
  @slow_job_threshold_ms
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/koderift/rails/configuration.rb', line 57

def valid?
  project_token.present?
end