honeybadger 1.16.7 → 2.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +19 -0
  3. data/README.md +37 -16
  4. data/bin/honeybadger +5 -0
  5. data/lib/honeybadger.rb +167 -191
  6. data/lib/honeybadger/agent.rb +136 -0
  7. data/lib/honeybadger/backend.rb +26 -0
  8. data/lib/honeybadger/backend/base.rb +66 -0
  9. data/lib/honeybadger/backend/debug.rb +12 -0
  10. data/lib/honeybadger/backend/null.rb +16 -0
  11. data/lib/honeybadger/backend/server.rb +51 -0
  12. data/lib/honeybadger/backend/test.rb +24 -0
  13. data/lib/honeybadger/backtrace.rb +29 -24
  14. data/lib/honeybadger/cli.rb +367 -0
  15. data/lib/honeybadger/config.rb +333 -0
  16. data/lib/honeybadger/config/callbacks.rb +70 -0
  17. data/lib/honeybadger/config/defaults.rb +175 -0
  18. data/lib/honeybadger/config/env.rb +40 -0
  19. data/lib/honeybadger/config/yaml.rb +43 -0
  20. data/lib/honeybadger/const.rb +28 -0
  21. data/lib/honeybadger/init/rails.rb +84 -0
  22. data/lib/honeybadger/init/sinatra.rb +27 -0
  23. data/lib/honeybadger/logging.rb +133 -0
  24. data/lib/honeybadger/notice.rb +243 -280
  25. data/lib/honeybadger/plugin.rb +110 -0
  26. data/lib/honeybadger/plugins/delayed_job.rb +22 -0
  27. data/lib/honeybadger/{integrations → plugins}/delayed_job/plugin.rb +6 -7
  28. data/lib/honeybadger/{integrations → plugins}/local_variables.rb +7 -8
  29. data/lib/honeybadger/{integrations → plugins}/net_http.rb +10 -8
  30. data/lib/honeybadger/plugins/passenger.rb +24 -0
  31. data/lib/honeybadger/plugins/rails.rb +61 -0
  32. data/lib/honeybadger/plugins/sidekiq.rb +35 -0
  33. data/lib/honeybadger/{integrations → plugins}/thor.rb +9 -8
  34. data/lib/honeybadger/{integrations → plugins}/unicorn.rb +10 -9
  35. data/lib/honeybadger/rack/error_notifier.rb +44 -27
  36. data/lib/honeybadger/rack/metrics_reporter.rb +41 -0
  37. data/lib/honeybadger/rack/request_hash.rb +50 -0
  38. data/lib/honeybadger/rack/user_feedback.rb +15 -10
  39. data/lib/honeybadger/rack/user_informer.rb +14 -3
  40. data/lib/honeybadger/trace.rb +185 -0
  41. data/lib/honeybadger/util/http.rb +79 -0
  42. data/lib/honeybadger/util/request_sanitizer.rb +35 -0
  43. data/lib/honeybadger/util/sanitizer.rb +71 -0
  44. data/lib/honeybadger/util/stats.rb +31 -0
  45. data/lib/honeybadger/version.rb +4 -0
  46. data/lib/honeybadger/worker.rb +224 -0
  47. data/lib/honeybadger/worker/batch.rb +50 -0
  48. data/lib/honeybadger/worker/metered_queue.rb +80 -0
  49. data/lib/honeybadger/worker/metrics_collection.rb +61 -0
  50. data/lib/honeybadger/worker/metrics_collector.rb +96 -0
  51. data/{lib/honeybadger/capistrano.rb → vendor/capistrano-honeybadger/lib/capistrano/honeybadger.rb} +1 -3
  52. data/vendor/capistrano-honeybadger/lib/capistrano/tasks/deploy.cap +76 -0
  53. data/vendor/capistrano-honeybadger/lib/honeybadger/capistrano.rb +2 -0
  54. data/{lib → vendor/capistrano-honeybadger/lib}/honeybadger/capistrano/legacy.rb +16 -15
  55. data/vendor/thor/lib/thor.rb +484 -0
  56. data/vendor/thor/lib/thor/actions.rb +319 -0
  57. data/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  58. data/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  59. data/vendor/thor/lib/thor/actions/directory.rb +118 -0
  60. data/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  61. data/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  62. data/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  63. data/vendor/thor/lib/thor/base.rb +656 -0
  64. data/vendor/thor/lib/thor/command.rb +133 -0
  65. data/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  66. data/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  67. data/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  68. data/vendor/thor/lib/thor/error.rb +32 -0
  69. data/vendor/thor/lib/thor/group.rb +281 -0
  70. data/vendor/thor/lib/thor/invocation.rb +178 -0
  71. data/vendor/thor/lib/thor/line_editor.rb +17 -0
  72. data/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  73. data/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  74. data/vendor/thor/lib/thor/parser.rb +4 -0
  75. data/vendor/thor/lib/thor/parser/argument.rb +73 -0
  76. data/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  77. data/vendor/thor/lib/thor/parser/option.rb +125 -0
  78. data/vendor/thor/lib/thor/parser/options.rb +218 -0
  79. data/vendor/thor/lib/thor/rake_compat.rb +71 -0
  80. data/vendor/thor/lib/thor/runner.rb +322 -0
  81. data/vendor/thor/lib/thor/shell.rb +81 -0
  82. data/vendor/thor/lib/thor/shell/basic.rb +421 -0
  83. data/vendor/thor/lib/thor/shell/color.rb +149 -0
  84. data/vendor/thor/lib/thor/shell/html.rb +126 -0
  85. data/vendor/thor/lib/thor/util.rb +267 -0
  86. data/vendor/thor/lib/thor/version.rb +3 -0
  87. metadata +97 -305
  88. data/Appraisals +0 -95
  89. data/CHANGELOG.md +0 -422
  90. data/Gemfile +0 -8
  91. data/Gemfile.lock +0 -136
  92. data/Guardfile +0 -5
  93. data/MIT-LICENSE +0 -32
  94. data/Rakefile +0 -159
  95. data/features/metal.feature +0 -20
  96. data/features/rack.feature +0 -55
  97. data/features/rails.feature +0 -343
  98. data/features/rails3.x.feature +0 -26
  99. data/features/rake.feature +0 -25
  100. data/features/sinatra.feature +0 -27
  101. data/features/standalone.feature +0 -73
  102. data/features/step_definitions/metal_steps.rb +0 -24
  103. data/features/step_definitions/rack_steps.rb +0 -18
  104. data/features/step_definitions/rails_steps.rb +0 -270
  105. data/features/step_definitions/rake_steps.rb +0 -17
  106. data/features/step_definitions/standalone_steps.rb +0 -12
  107. data/features/step_definitions/thor_steps.rb +0 -4
  108. data/features/support/env.rb +0 -22
  109. data/features/support/honeybadger_failure_shim.rb.template +0 -5
  110. data/features/support/honeybadger_shim.rb.template +0 -6
  111. data/features/support/rails.rb +0 -202
  112. data/features/support/rake/Rakefile +0 -68
  113. data/features/support/test.thor +0 -22
  114. data/features/thor.feature +0 -5
  115. data/gemfiles/binding_of_caller.gemfile +0 -13
  116. data/gemfiles/delayed_job.gemfile +0 -13
  117. data/gemfiles/rack.gemfile +0 -13
  118. data/gemfiles/rails.gemfile +0 -16
  119. data/gemfiles/rails2.3.gemfile +0 -15
  120. data/gemfiles/rails3.0.gemfile +0 -16
  121. data/gemfiles/rails3.1.gemfile +0 -16
  122. data/gemfiles/rails3.2.gemfile +0 -16
  123. data/gemfiles/rails4.0.gemfile +0 -16
  124. data/gemfiles/rails4.1.gemfile +0 -16
  125. data/gemfiles/rake.gemfile +0 -13
  126. data/gemfiles/sinatra.gemfile +0 -13
  127. data/gemfiles/standalone.gemfile +0 -12
  128. data/gemfiles/thor.gemfile +0 -13
  129. data/generators/honeybadger/honeybadger_generator.rb +0 -95
  130. data/generators/honeybadger/lib/insert_commands.rb +0 -34
  131. data/generators/honeybadger/lib/rake_commands.rb +0 -24
  132. data/generators/honeybadger/templates/capistrano_hook.rb +0 -6
  133. data/generators/honeybadger/templates/honeybadger_tasks.rake +0 -25
  134. data/generators/honeybadger/templates/initializer.rb +0 -6
  135. data/honeybadger.gemspec +0 -174
  136. data/lib/honeybadger/array.rb +0 -53
  137. data/lib/honeybadger/capistrano/tasks.rake +0 -73
  138. data/lib/honeybadger/configuration.rb +0 -397
  139. data/lib/honeybadger/dependency.rb +0 -65
  140. data/lib/honeybadger/integrations.rb +0 -9
  141. data/lib/honeybadger/integrations/delayed_job.rb +0 -20
  142. data/lib/honeybadger/integrations/passenger.rb +0 -18
  143. data/lib/honeybadger/integrations/sidekiq.rb +0 -37
  144. data/lib/honeybadger/monitor.rb +0 -17
  145. data/lib/honeybadger/monitor/railtie.rb +0 -53
  146. data/lib/honeybadger/monitor/sender.rb +0 -44
  147. data/lib/honeybadger/monitor/trace.rb +0 -187
  148. data/lib/honeybadger/monitor/worker.rb +0 -169
  149. data/lib/honeybadger/payload.rb +0 -101
  150. data/lib/honeybadger/rack.rb +0 -12
  151. data/lib/honeybadger/rails.rb +0 -45
  152. data/lib/honeybadger/rails/action_controller_catcher.rb +0 -30
  153. data/lib/honeybadger/rails/controller_methods.rb +0 -78
  154. data/lib/honeybadger/rails/middleware/exceptions_catcher.rb +0 -29
  155. data/lib/honeybadger/rails3_tasks.rb +0 -94
  156. data/lib/honeybadger/railtie.rb +0 -52
  157. data/lib/honeybadger/rake_handler.rb +0 -66
  158. data/lib/honeybadger/sender.rb +0 -185
  159. data/lib/honeybadger/shared_tasks.rb +0 -56
  160. data/lib/honeybadger/stats.rb +0 -29
  161. data/lib/honeybadger/tasks.rb +0 -95
  162. data/lib/honeybadger/user_feedback.rb +0 -8
  163. data/lib/honeybadger/user_informer.rb +0 -8
  164. data/lib/honeybadger_tasks.rb +0 -69
  165. data/lib/rails/generators/honeybadger/honeybadger_generator.rb +0 -99
  166. data/rails/init.rb +0 -1
  167. data/resources/README.md +0 -34
  168. data/script/integration_test.rb +0 -38
  169. data/spec/allocation_stats.rb +0 -32
  170. data/spec/honeybadger/backtrace_spec.rb +0 -242
  171. data/spec/honeybadger/capistrano_spec.rb +0 -36
  172. data/spec/honeybadger/configuration_spec.rb +0 -328
  173. data/spec/honeybadger/dependency_spec.rb +0 -134
  174. data/spec/honeybadger/integrations/delayed_job_spec.rb +0 -82
  175. data/spec/honeybadger/integrations/local_variables_spec.rb +0 -60
  176. data/spec/honeybadger/integrations/net_http_spec.rb +0 -29
  177. data/spec/honeybadger/integrations/passenger_spec.rb +0 -29
  178. data/spec/honeybadger/integrations/sidekiq_spec.rb +0 -60
  179. data/spec/honeybadger/integrations/thor_spec.rb +0 -32
  180. data/spec/honeybadger/integrations/unicorn_spec.rb +0 -40
  181. data/spec/honeybadger/logger_spec.rb +0 -79
  182. data/spec/honeybadger/monitor/trace_spec.rb +0 -65
  183. data/spec/honeybadger/monitor/worker_spec.rb +0 -274
  184. data/spec/honeybadger/notice_spec.rb +0 -669
  185. data/spec/honeybadger/notifier_spec.rb +0 -328
  186. data/spec/honeybadger/payload_spec.rb +0 -162
  187. data/spec/honeybadger/rack_spec.rb +0 -85
  188. data/spec/honeybadger/rails/action_controller_spec.rb +0 -328
  189. data/spec/honeybadger/rails_spec.rb +0 -37
  190. data/spec/honeybadger/sender_spec.rb +0 -317
  191. data/spec/honeybadger/stats_spec.rb +0 -57
  192. data/spec/honeybadger/user_feedback_spec.rb +0 -80
  193. data/spec/honeybadger/user_informer_spec.rb +0 -30
  194. data/spec/honeybadger_tasks_spec.rb +0 -171
  195. data/spec/spec_helper.rb +0 -24
  196. data/spec/support/array_including.rb +0 -31
  197. data/spec/support/backtraced_exception.rb +0 -9
  198. data/spec/support/collected_sender.rb +0 -12
  199. data/spec/support/defines_constants.rb +0 -18
  200. data/spec/support/helpers.rb +0 -101
@@ -1,53 +0,0 @@
1
- # This code comes from batsd - I just decided to put this in a child
2
- # class rather than re-opening Array.
3
- class Honeybadger::Array < Array
4
- # Calculates the sum of values in the array
5
- def sum
6
- inject( nil ) { |sum,x| sum ? sum+x : x };
7
- end
8
-
9
- # Calculates the arithmetic mean of values in the array
10
- def mean
11
- self.sum.to_f / self.length
12
- end
13
-
14
- # Calculates the median of values in the array
15
- def median
16
- self.sort[self.length/2]
17
- end
18
-
19
- # Calculates the value of the upper percentile of values
20
- # in the array. If only a single value is provided in the array, that is
21
- # returned
22
- def percentile(threshold)
23
- if (count > 1)
24
- self.sort!
25
- # strip off the top 100-threshold
26
- threshold_index = (((100 - threshold).to_f / 100) * count).round
27
- self[0..-threshold_index].last
28
- else
29
- self.first
30
- end
31
- end
32
-
33
- # Calculates the mean squared error of values in the array
34
- def mean_squared
35
- m = mean
36
- self.class.new(map{|v| (v-m)**2}).sum
37
- end
38
-
39
- # Calculates the standard deviatiation of values in the array
40
- def standard_dev
41
- (mean_squared/(count-1))**0.5
42
- end
43
-
44
- # Allow [1,2,3].percentile_90, [1,2,3].percentile(75), etc.
45
- def method_missing(method, *args, &block)
46
- if method.to_s =~ /^percentile_(.+)$/
47
- percentile($1.to_i)
48
- else
49
- super
50
- end
51
- end
52
-
53
- end
@@ -1,73 +0,0 @@
1
- namespace :honeybadger do
2
- def sshkit_outdated?
3
- !::SSHKit.config.command_map.respond_to?(:prefix)
4
- end
5
-
6
- desc 'Notify Honeybadger of the deployment.'
7
- task :deploy => :env do
8
- next if sshkit_outdated?
9
- if server = fetch(:honeybadger_server)
10
- on server do |host|
11
- info 'Notifying Honeybadger of deploy.'
12
-
13
- executable = RUBY_PLATFORM.downcase.include?('mswin') ? fetch(:rake, :'rake.bat') : fetch(:rake, :rake)
14
- rake_task = fetch(:honeybadger_deploy_task, 'honeybadger:deploy')
15
-
16
- options = [rake_task]
17
-
18
- if fetch(:honeybadger_async_notify, false)
19
- ::SSHKit.config.command_map.prefix[:rake].push(:nohup)
20
- options << '>> /dev/null 2>&1 &'
21
- end
22
-
23
- within release_path do
24
- execute executable, options
25
- end
26
-
27
- info 'Honeybadger notification complete.'
28
- end
29
- end
30
- end
31
-
32
- desc 'Setup ENV for Honeybadger deploy rake task.'
33
- task :env do
34
- if sshkit_outdated?
35
- run_locally do
36
- warn 'Unable to notify Honeybadger: you are using an outdated version of SSHKIT. Please upgrade to >= 1.2.0.'
37
- end
38
- next
39
- end
40
-
41
- server = fetch(:honeybadger_server) do
42
- if s = primary(:app)
43
- set(:honeybadger_server, s.select?({ :exclude => :no_release }) ? s : nil)
44
- end
45
- end
46
-
47
- unless server
48
- run_locally do
49
- warn 'Unable to notify Honeybadger: could not find app server for notification. Try setting honeybadger_server.'
50
- end
51
- next
52
- end
53
-
54
- on server do |host|
55
- rails_env = fetch(:rails_env, "production")
56
- honeybadger_env = fetch(:honeybadger_env, rails_env)
57
- repository = fetch(:repo_url)
58
- local_user = fetch(:honeybadger_user, ENV['USER'] || ENV['USERNAME'])
59
- api_key = fetch(:honeybadger_api_key, ENV['HONEYBADGER_API_KEY'] || ENV['API_KEY'])
60
- revision = fetch(:current_revision) do
61
- within(repo_path) do
62
- capture("cd #{repo_path} && git rev-parse --short HEAD")
63
- end
64
- end
65
-
66
- env = ["RAILS_ENV=#{rails_env}", "TO=#{honeybadger_env}", "REVISION=#{revision}", "REPO=#{repository}", "USER=#{local_user}"]
67
- env << "API_KEY=#{api_key}" if api_key
68
- ::SSHKit.config.command_map.prefix[:rake].unshift(*env)
69
- end
70
- end
71
- end
72
-
73
- after 'deploy:finishing', 'honeybadger:deploy'
@@ -1,397 +0,0 @@
1
- require 'socket'
2
-
3
- module Honeybadger
4
- class Configuration
5
- OPTIONS = [:api_key, :backtrace_filters, :development_environments, :environment_name,
6
- :host, :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
7
- :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
8
- :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass,
9
- :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain, :framework,
10
- :user_information, :feedback, :rescue_rake_exceptions, :source_extract_radius,
11
- :send_request_session, :debug, :fingerprint, :hostname, :features, :metrics,
12
- :log_exception_on_send_failure, :send_local_variables, :traces,
13
- :trace_threshold, :unwrap_exceptions, :delayed_job_attempt_threshold].freeze
14
-
15
- # The API key for your project, found on the project edit form.
16
- attr_accessor :api_key
17
-
18
- # The host to connect to (defaults to honeybadger.io).
19
- attr_accessor :host
20
-
21
- # The port on which your Honeybadger server runs (defaults to 443 for secure
22
- # connections, 80 for insecure connections).
23
- attr_accessor :port
24
-
25
- # +true+ for https connections, +false+ for http connections.
26
- attr_accessor :secure
27
-
28
- # +true+ to use whatever CAs OpenSSL has installed on your system. +false+ to use the ca-bundle.crt file included in Honeybadger itself (reccomended and default)
29
- attr_accessor :use_system_ssl_cert_chain
30
-
31
- # The HTTP open timeout in seconds (defaults to 2).
32
- attr_accessor :http_open_timeout
33
-
34
- # The HTTP read timeout in seconds (defaults to 5).
35
- attr_accessor :http_read_timeout
36
-
37
- # The hostname of your proxy server (if using a proxy)
38
- attr_accessor :proxy_host
39
-
40
- # The port of your proxy server (if using a proxy)
41
- attr_accessor :proxy_port
42
-
43
- # The username to use when logging into your proxy server (if using a proxy)
44
- attr_accessor :proxy_user
45
-
46
- # The password to use when logging into your proxy server (if using a proxy)
47
- attr_accessor :proxy_pass
48
-
49
- # A list of parameters that should be filtered out of what is sent to Honeybadger.
50
- # By default, all "password" attributes will have their contents replaced.
51
- attr_reader :params_filters
52
-
53
- # A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
54
- attr_reader :backtrace_filters
55
-
56
- # A list of filters for ignoring exceptions. See #ignore_by_filter.
57
- attr_reader :ignore_by_filters
58
-
59
- # A list of exception classes to ignore. The array can be appended to.
60
- attr_reader :ignore
61
-
62
- # A list of user agents that are being ignored. The array can be appended to.
63
- attr_reader :ignore_user_agent
64
-
65
- # Traces must have a duration greater than this (in ms) to be recorded
66
- attr_reader :trace_threshold
67
-
68
- # A list of environments in which notifications should not be sent.
69
- attr_accessor :development_environments
70
-
71
- # The name of the environment the application is running in
72
- attr_accessor :environment_name
73
-
74
- # The path to the project in which the error occurred, such as the Rails.root
75
- attr_accessor :project_root
76
-
77
- # The name of the notifier library being used to send notifications (such as "Honeybadger Notifier")
78
- attr_accessor :notifier_name
79
-
80
- # The version of the notifier library being used to send notifications (such as "1.0.2")
81
- attr_accessor :notifier_version
82
-
83
- # The url of the notifier library being used to send notifications
84
- attr_accessor :notifier_url
85
-
86
- # The logger used by Honeybadger
87
- attr_accessor :logger
88
-
89
- # The text that the placeholder is replaced with. {{error_id}} is the actual error number.
90
- attr_accessor :user_information
91
-
92
- # Display user feedback form when configured?
93
- attr_accessor :feedback
94
-
95
- # The framework Honeybadger is configured to use.
96
- attr_accessor :framework
97
-
98
- # Should Honeybadger catch exceptions from Rake tasks?
99
- # (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
100
- attr_accessor :rescue_rake_exceptions
101
-
102
- # The radius around trace line to include in source excerpt
103
- attr_accessor :source_extract_radius
104
-
105
- # +true+ to send session data, +false+ to exclude
106
- attr_accessor :send_request_session
107
-
108
- # +true+ to send local variables, +false+ to exclude
109
- attr_accessor :send_local_variables
110
-
111
- # +true+ to unwrap exceptions
112
- attr_accessor :unwrap_exceptions
113
-
114
- # +true+ to log extra debug info, +false+ to suppress
115
- attr_accessor :debug
116
-
117
- # +true+ to log the original exception on send failure, +false+ to suppress
118
- attr_accessor :log_exception_on_send_failure
119
-
120
- # A Proc object used to send notices asynchronously
121
- attr_writer :async
122
-
123
- # A Proc object used to generate optional fingerprint
124
- attr_writer :fingerprint
125
-
126
- # Override the hostname of the local server (optional)
127
- attr_accessor :hostname
128
-
129
- # Send metrics?
130
- attr_accessor :metrics
131
-
132
- # Send traces?
133
- attr_accessor :traces
134
-
135
- # Which features the API says we have
136
- attr_accessor :features
137
-
138
- # Do not notify unless Delayed Job attempts reaches or exceeds this value
139
- attr_accessor :delayed_job_attempt_threshold
140
-
141
- DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
142
-
143
- DEFAULT_BACKTRACE_FILTERS = [
144
- lambda { |line|
145
- if defined?(Honeybadger.configuration.project_root) && Honeybadger.configuration.project_root.to_s != ''
146
- line.sub(/#{Honeybadger.configuration.project_root}/, "[PROJECT_ROOT]")
147
- else
148
- line
149
- end
150
- },
151
- lambda { |line| line.gsub(/^\.\//, "") },
152
- lambda { |line|
153
- if defined?(Gem)
154
- Gem.path.inject(line) do |line, path|
155
- line.gsub(/#{path}/, "[GEM_ROOT]")
156
- end
157
- end
158
- },
159
- lambda { |line| line if line !~ %r{lib/honeybadger} }
160
- ].freeze
161
-
162
- IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
163
- 'ActionController::RoutingError',
164
- 'ActionController::InvalidAuthenticityToken',
165
- 'CGI::Session::CookieStore::TamperedWithCookie',
166
- 'ActionController::UnknownAction',
167
- 'AbstractController::ActionNotFound',
168
- 'Mongoid::Errors::DocumentNotFound',
169
- 'Sinatra::NotFound',
170
- 'ActionController::UnknownFormat']
171
-
172
- alias_method :secure?, :secure
173
- alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
174
-
175
- def initialize
176
- @api_key = ENV['HONEYBADGER_API_KEY']
177
- @secure = true
178
- @use_system_ssl_cert_chain = false
179
- @host = 'api.honeybadger.io'
180
- @http_open_timeout = 2
181
- @http_read_timeout = 5
182
- @params_filters = DEFAULT_PARAMS_FILTERS.dup
183
- @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
184
- @ignore_by_filters = []
185
- @ignore = IGNORE_DEFAULT.dup
186
- @ignore_user_agent = []
187
- @development_environments = %w(development test cucumber)
188
- @notifier_name = 'Honeybadger Notifier'
189
- @notifier_version = VERSION
190
- @notifier_url = 'https://github.com/honeybadger-io/honeybadger-ruby'
191
- @framework = 'Standalone'
192
- @user_information = 'Honeybadger Error {{error_id}}'
193
- @rescue_rake_exceptions = nil
194
- @source_extract_radius = 2
195
- @send_request_session = true
196
- @send_local_variables = false
197
- @debug = false
198
- @log_exception_on_send_failure = false
199
- @hostname = Socket.gethostname
200
- @metrics = true
201
- @features = {'notices' => true, 'local_variables' => true}
202
- @traces = true
203
- @limit = nil
204
- @feedback = true
205
- @trace_threshold = 2000
206
- @unwrap_exceptions = true
207
- @delayed_job_attempt_threshold = 0
208
- end
209
-
210
- # Public: Takes a block and adds it to the list of backtrace filters. When
211
- # the filters run, the block will be handed each line of the backtrace and
212
- # can modify it as necessary.
213
- #
214
- # &block - The new backtrace filter.
215
- #
216
- # Examples:
217
- #
218
- # config.filter_bracktrace do |line|
219
- # line.gsub(/^#{Rails.root}/, "[Rails.root]")
220
- # end
221
- #
222
- # Yields a line in the backtrace.
223
- def filter_backtrace(&block)
224
- self.backtrace_filters << block
225
- end
226
-
227
- # Public: Takes a block and adds it to the list of ignore filters. When
228
- # the filters run, the block will be handed the exception.
229
- #
230
- # &block - The new ignore filter
231
- # If the block returns true the exception will be ignored, otherwise it
232
- # will be processed by honeybadger.
233
- #
234
- # Examples:
235
- #
236
- # config.ignore_by_filter do |exception_data|
237
- # true if exception_data[:error_class] == "RuntimeError"
238
- # end
239
- #
240
- # Yields the the exception data given to Honeybadger.notify
241
- def ignore_by_filter(&block)
242
- self.ignore_by_filters << block
243
- end
244
-
245
- # Public: Overrides the list of default ignored errors.
246
- #
247
- # names - A list of exceptions to ignore.
248
- #
249
- # Returns nothing
250
- def ignore_only=(names)
251
- @ignore = [names].flatten
252
- end
253
-
254
- # Public: Overrides the list of default ignored user agents
255
- #
256
- # names - A list of user agents to ignore
257
- #
258
- # Returns nothing
259
- def ignore_user_agent_only=(names)
260
- @ignore_user_agent = [names].flatten
261
- end
262
-
263
- def trace_threshold=(threshold)
264
- @trace_threshold = [threshold, 1000].max
265
- end
266
-
267
- # Public: Allows config options to be read like a hash
268
- #
269
- # option - Key for a given attribute
270
- #
271
- # Returns value of requested attribute
272
- def [](option)
273
- send(option)
274
- end
275
-
276
- # Public
277
- # Returns a hash of all configurable options
278
- def to_hash
279
- OPTIONS.inject({}) do |hash, option|
280
- hash[option.to_sym] = self.send(option)
281
- hash
282
- end
283
- end
284
-
285
- # Public
286
- #
287
- # hash - A set of configuration options that will take precedence over the defaults
288
- #
289
- # Returns a hash of all configurable options merged with +hash+
290
- def merge(hash)
291
- to_hash.merge(hash)
292
- end
293
-
294
- # Public: Determines if the notifier will send notices.
295
- #
296
- # Returns true if allowed to talk to API, false otherwise.
297
- def public?
298
- api_key =~ /\S/ && !development_environments.include?(environment_name)
299
- end
300
-
301
- # Public: Determines whether to send metrics
302
- #
303
- def metrics?
304
- public? && @metrics
305
- end
306
-
307
- # Public: Determines whether to send traces
308
- #
309
- def traces?
310
- public? && @traces
311
- end
312
-
313
- # Public: Configure async delivery
314
- #
315
- # block - An optional block containing an async handler
316
- #
317
- # Examples
318
- #
319
- # config.async = Proc.new { |notice| Thread.new { Honeybadger.sender.send_to_honeybadger(notice) } }
320
- #
321
- # config.async do |notice|
322
- # Thread.new { Honeybadger.sender.send_to_honeybadger(notice) }
323
- # end
324
- #
325
- # Returns configured async handler (should respond to #call(notice))
326
- def async
327
- @async = Proc.new if block_given?
328
- @async
329
- end
330
- alias :async? :async
331
-
332
- # Public: Generate custom fingerprint (optional)
333
- #
334
- # block - An optional block returning object responding to #to_s
335
- #
336
- # Examples
337
- #
338
- # config.fingerprint = Proc.new { |notice| ... }
339
- #
340
- # config.fingerprint do |notice|
341
- # [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
342
- # end
343
- #
344
- # Returns configured fingerprint generator (should respond to #call(notice))
345
- def fingerprint
346
- @fingerprint = Proc.new if block_given?
347
- @fingerprint
348
- end
349
-
350
- def port
351
- @port || default_port
352
- end
353
-
354
- # Public: Determines whether protocol should be "http" or "https".
355
- #
356
- # Returns 'http' if you've set secure to false in
357
- # configuration, and 'https' otherwise.
358
- def protocol
359
- if secure?
360
- 'https'
361
- else
362
- 'http'
363
- end
364
- end
365
-
366
- def ca_bundle_path
367
- if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
368
- OpenSSL::X509::DEFAULT_CERT_FILE
369
- else
370
- local_cert_path # ca-bundle.crt built from source, see resources/README.md
371
- end
372
- end
373
-
374
- def local_cert_path
375
- File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
376
- end
377
-
378
- # Stub deprecated current_user_method configuration option
379
- # This should be removed completely once everyone has updated to > 1.2
380
- def current_user_method=(null) ; end
381
-
382
- private
383
-
384
- # Private: Determines what port should we use for sending notices.
385
- #
386
- # Returns 443 if you've set secure to true in your
387
- # configuration, and 80 otherwise.
388
- def default_port
389
- if secure?
390
- 443
391
- else
392
- 80
393
- end
394
- end
395
- end
396
- end
397
-