Class: Bugsnag::Configuration

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

Constant Summary collapse

THREAD_LOCAL_NAME =
"bugsnag_req_data"
DEFAULT_ENDPOINT =
"notify.bugsnag.com"
DEFAULT_PARAMS_FILTERS =
[
  /authorization/i,
  /cookie/i,
  /password/i,
  /secret/i,
  "rack.request.form_vars"
].freeze
DEFAULT_IGNORE_CLASSES =
[
  "AbstractController::ActionNotFound",
  "ActionController::InvalidAuthenticityToken",
  "ActionController::ParameterMissing",
  "ActionController::RoutingError",
  "ActionController::UnknownAction",
  "ActionController::UnknownFormat",
  "ActionController::UnknownHttpMethod",
  "ActiveRecord::RecordNotFound",
  "CGI::Session::CookieStore::TamperedWithCookie",
  "Mongoid::Errors::DocumentNotFound",
  "SignalException",
  "SystemExit",
].freeze
DEFAULT_IGNORE_USER_AGENTS =
[].freeze
DEFAULT_DELIVERY_METHOD =
:thread_queue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bugsnag/configuration.rb', line 68

def initialize
  @mutex = Mutex.new

  # Set up the defaults
  self.auto_notify = true
  self.use_ssl = true
  self.send_environment = false
  self.send_code = true
  self.params_filters = Set.new(DEFAULT_PARAMS_FILTERS)
  self.ignore_classes = Set.new(DEFAULT_IGNORE_CLASSES)
  self.ignore_user_agents = Set.new(DEFAULT_IGNORE_USER_AGENTS)
  self.endpoint = DEFAULT_ENDPOINT
  self.hostname = default_hostname
  self.delivery_method = DEFAULT_DELIVERY_METHOD
  self.timeout = 15
  self.vendor_paths = [%r{vendor/}]

  # Read the API key from the environment
  self.api_key = ENV["BUGSNAG_API_KEY"]

  # Set up logging
  self.logger = Logger.new(STDOUT)
  self.logger.level = Logger::WARN

  # Configure the bugsnag middleware stack
  self.internal_middleware = Bugsnag::MiddlewareStack.new

  self.middleware = Bugsnag::MiddlewareStack.new
  self.middleware.use Bugsnag::Middleware::Callbacks
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#app_typeObject

Returns the value of attribute app_type.



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

def app_type
  @app_type
end

#app_versionObject

Returns the value of attribute app_version.



18
19
20
# File 'lib/bugsnag/configuration.rb', line 18

def app_version
  @app_version
end

#auto_notifyObject

Returns the value of attribute auto_notify.



11
12
13
# File 'lib/bugsnag/configuration.rb', line 11

def auto_notify
  @auto_notify
end

#ca_fileObject

Returns the value of attribute ca_file.



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

def ca_file
  @ca_file
end

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#delay_with_resqueObject

Returns the value of attribute delay_with_resque.



26
27
28
# File 'lib/bugsnag/configuration.rb', line 26

def delay_with_resque
  @delay_with_resque
end

#delivery_methodObject

Returns the value of attribute delivery_method.



34
35
36
# File 'lib/bugsnag/configuration.rb', line 34

def delivery_method
  @delivery_method
end

#endpointObject

Returns the value of attribute endpoint.



22
23
24
# File 'lib/bugsnag/configuration.rb', line 22

def endpoint
  @endpoint
end

#hostnameObject

Returns the value of attribute hostname.



33
34
35
# File 'lib/bugsnag/configuration.rb', line 33

def hostname
  @hostname
end

#ignore_classesObject

Accept both String and Class instances as an ignored class



100
101
102
# File 'lib/bugsnag/configuration.rb', line 100

def ignore_classes
  @mutex.synchronize { @ignore_classes.map! { |klass| klass.is_a?(Class) ? klass.name : klass } }
end

#ignore_user_agentsObject

Returns the value of attribute ignore_user_agents.



21
22
23
# File 'lib/bugsnag/configuration.rb', line 21

def ignore_user_agents
  @ignore_user_agents
end

#internal_middlewareObject

Returns the value of attribute internal_middleware.



25
26
27
# File 'lib/bugsnag/configuration.rb', line 25

def internal_middleware
  @internal_middleware
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#middlewareObject

Returns the value of attribute middleware.



24
25
26
# File 'lib/bugsnag/configuration.rb', line 24

def middleware
  @middleware
end

#notify_release_stagesObject

Returns the value of attribute notify_release_stages.



10
11
12
# File 'lib/bugsnag/configuration.rb', line 10

def notify_release_stages
  @notify_release_stages
end

#params_filtersObject

Returns the value of attribute params_filters.



20
21
22
# File 'lib/bugsnag/configuration.rb', line 20

def params_filters
  @params_filters
end

#project_rootObject

Returns the value of attribute project_root.



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

def project_root
  @project_root
end

#proxy_hostObject

Returns the value of attribute proxy_host.



28
29
30
# File 'lib/bugsnag/configuration.rb', line 28

def proxy_host
  @proxy_host
end

#proxy_passwordObject

Returns the value of attribute proxy_password.



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

def proxy_password
  @proxy_password
end

#proxy_portObject

Returns the value of attribute proxy_port.



29
30
31
# File 'lib/bugsnag/configuration.rb', line 29

def proxy_port
  @proxy_port
end

#proxy_userObject

Returns the value of attribute proxy_user.



30
31
32
# File 'lib/bugsnag/configuration.rb', line 30

def proxy_user
  @proxy_user
end

#release_stageObject

Returns the value of attribute release_stage.



9
10
11
# File 'lib/bugsnag/configuration.rb', line 9

def release_stage
  @release_stage
end

#send_codeObject

Returns the value of attribute send_code.



15
16
17
# File 'lib/bugsnag/configuration.rb', line 15

def send_code
  @send_code
end

#send_environmentObject

Returns the value of attribute send_environment.



14
15
16
# File 'lib/bugsnag/configuration.rb', line 14

def send_environment
  @send_environment
end

#timeoutObject

Returns the value of attribute timeout.



32
33
34
# File 'lib/bugsnag/configuration.rb', line 32

def timeout
  @timeout
end

#use_sslObject

Returns the value of attribute use_ssl.



12
13
14
# File 'lib/bugsnag/configuration.rb', line 12

def use_ssl
  @use_ssl
end

#vendor_pathsObject

Returns the value of attribute vendor_paths.



17
18
19
# File 'lib/bugsnag/configuration.rb', line 17

def vendor_paths
  @vendor_paths
end

Instance Method Details

#clear_request_dataObject



120
121
122
# File 'lib/bugsnag/configuration.rb', line 120

def clear_request_data
  Thread.current[THREAD_LOCAL_NAME] = nil
end

#request_dataObject



108
109
110
# File 'lib/bugsnag/configuration.rb', line 108

def request_data
  Thread.current[THREAD_LOCAL_NAME] ||= {}
end

#set_request_data(key, value) ⇒ Object



112
113
114
# File 'lib/bugsnag/configuration.rb', line 112

def set_request_data(key, value)
  self.request_data[key] = value
end

#should_notify?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/bugsnag/configuration.rb', line 104

def should_notify?
  @release_stage.nil? || @notify_release_stages.nil? || @notify_release_stages.include?(@release_stage)
end

#unset_request_data(key, value) ⇒ Object



116
117
118
# File 'lib/bugsnag/configuration.rb', line 116

def unset_request_data(key, value)
  self.request_data.delete(key)
end