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 =
["password", "secret", "rack.request.form_vars"].freeze
DEFAULT_IGNORE_CLASSES =
[
  "ActiveRecord::RecordNotFound",
  "ActionController::RoutingError",
  "ActionController::InvalidAuthenticityToken",
  "CGI::Session::CookieStore::TamperedWithCookie",
  "ActionController::UnknownAction",
  "AbstractController::ActionNotFound",
  "Mongoid::Errors::DocumentNotFound",
  "SystemExit",
  "SignalException"
].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.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bugsnag/configuration.rb', line 57

def initialize
  # 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

  # 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.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.



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

def app_type
  @app_type
end

#app_versionObject

Returns the value of attribute app_version.



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

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

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#delay_with_resqueObject

Returns the value of attribute delay_with_resque.



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

def delay_with_resque
  @delay_with_resque
end

#delivery_methodObject

Returns the value of attribute delivery_method.



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

def delivery_method
  @delivery_method
end

#endpointObject

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

#hostnameObject

Returns the value of attribute hostname.



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

def hostname
  @hostname
end

#ignore_classesObject

Accept both String and Class instances as an ignored class



83
84
85
# File 'lib/bugsnag/configuration.rb', line 83

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

#ignore_user_agentsObject

Returns the value of attribute ignore_user_agents.



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

def ignore_user_agents
  @ignore_user_agents
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#middlewareObject

Returns the value of attribute middleware.



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

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.



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

def params_filters
  @params_filters
end

#project_rootObject

Returns the value of attribute project_root.



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

def project_root
  @project_root
end

#proxy_hostObject

Returns the value of attribute proxy_host.



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

def proxy_host
  @proxy_host
end

#proxy_passwordObject

Returns the value of attribute proxy_password.



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

def proxy_password
  @proxy_password
end

#proxy_portObject

Returns the value of attribute proxy_port.



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

def proxy_port
  @proxy_port
end

#proxy_userObject

Returns the value of attribute proxy_user.



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

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.



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

def send_code
  @send_code
end

#send_environmentObject

Returns the value of attribute send_environment.



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

def send_environment
  @send_environment
end

#timeoutObject

Returns the value of attribute timeout.



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

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

Instance Method Details

#clear_request_dataObject



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

def clear_request_data
  Thread.current[THREAD_LOCAL_NAME] = nil
end

#request_dataObject



91
92
93
# File 'lib/bugsnag/configuration.rb', line 91

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

#set_request_data(key, value) ⇒ Object



95
96
97
# File 'lib/bugsnag/configuration.rb', line 95

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

#should_notify?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/bugsnag/configuration.rb', line 87

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

#unset_request_data(key, value) ⇒ Object



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

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