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,29 +0,0 @@
1
- module Honeybadger
2
- class Stats
3
- HAS_MEM = File.exists?("/proc/meminfo")
4
- HAS_LOAD = File.exists?("/proc/loadavg")
5
-
6
- class << self
7
- def all
8
- { :mem => memory, :load => load }
9
- end
10
-
11
- # From https://github.com/bloopletech/webstats/blob/master/server/data_providers/mem_info.rb
12
- def memory
13
- out = {}
14
- if HAS_MEM
15
- out[:total], out[:free], out[:buffers], out[:cached] = IO.readlines("/proc/meminfo")[0..4].map { |l| l =~ /^.*?\: +(.*?) kB$/; ($1.to_i / 1024.0).to_f }
16
- out[:free_total] = out[:free] + out[:buffers] + out[:cached]
17
- end
18
- out
19
- end
20
-
21
- # From https://github.com/bloopletech/webstats/blob/master/server/data_providers/cpu_info.rb
22
- def load
23
- out = {}
24
- out[:one], out[:five], out[:fifteen] = IO.read("/proc/loadavg").split(' ', 4).map(&:to_f) if HAS_LOAD
25
- out
26
- end
27
- end
28
- end
29
- end
@@ -1,95 +0,0 @@
1
- require 'honeybadger'
2
- require File.join(File.dirname(__FILE__), 'shared_tasks')
3
-
4
- namespace :honeybadger do
5
- desc "Verify your gem installation by sending a test exception to the honeybadger service"
6
- task :test => ['honeybadger:log_stdout', :environment] do
7
- RAILS_DEFAULT_LOGGER.level = Logger::INFO
8
-
9
- require 'action_controller/test_process'
10
-
11
- begin
12
- Dir["app/controllers/application*.rb"].each { |file| require(File.expand_path(file)) }
13
- rescue LoadError
14
- nil
15
- end
16
-
17
- class HoneybadgerTestingException < RuntimeError; end
18
-
19
- unless Honeybadger.configuration.api_key
20
- puts "Honeybadger needs an API key configured! Check the README to see how to add it."
21
- exit
22
- end
23
-
24
- if Honeybadger.configuration.async?
25
- puts "Temporarily disabling asynchronous delivery"
26
- Honeybadger.configuration.async = nil
27
- end
28
-
29
- Honeybadger.configure(true) do |config|
30
- config.debug = true
31
- config.development_environments = []
32
- config.rescue_rake_exceptions = false
33
- end
34
-
35
- puts "Configuration:"
36
- Honeybadger.configuration.to_hash.each do |key, value|
37
- puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
38
- end
39
-
40
- unless defined?(ApplicationController)
41
- puts "No ApplicationController found"
42
- exit
43
- end
44
-
45
- catcher = Honeybadger::Rails::ActionControllerCatcher
46
- in_controller = ApplicationController.included_modules.include?(catcher)
47
- in_base = ActionController::Base.included_modules.include?(catcher)
48
- if !in_controller || !in_base
49
- puts "Rails initialization did not occur"
50
- exit
51
- end
52
-
53
- puts 'Setting up the Controller.'
54
- class ApplicationController
55
- # This is to bypass any filters that may prevent access to the action.
56
- prepend_before_filter :test_honeybadger
57
- def test_honeybadger
58
- puts "Raising '#{exception_class.name}' to simulate application failure."
59
- raise exception_class.new, 'Testing honeybadger via "rake honeybadger:test". If you can see this, it works.'
60
- end
61
-
62
- def rescue_action(exception)
63
- rescue_action_in_public exception
64
- end
65
-
66
- # Ensure we actually have an action to go to.
67
- def verify; end
68
-
69
- def consider_all_requests_local
70
- false
71
- end
72
-
73
- def local_request?
74
- false
75
- end
76
-
77
- def exception_class
78
- exception_name = ENV['EXCEPTION'] || "HoneybadgerTestingException"
79
- exception_name.split("::").inject(Object){|klass, name| klass.const_get(name)}
80
- rescue
81
- Object.const_set(exception_name.gsub(/:+/, "_"), Class.new(Exception))
82
- end
83
-
84
- def logger
85
- nil
86
- end
87
- end
88
- class HoneybadgerVerificationController < ApplicationController; end
89
-
90
- puts 'Processing request.'
91
- request = ActionController::TestRequest.new("REQUEST_URI" => "/honeybadger_verification_controller")
92
- response = ActionController::TestResponse.new
93
- HoneybadgerVerificationController.new.process(request, response)
94
- end
95
- end
@@ -1,8 +0,0 @@
1
- module Honeybadger
2
- class UserFeedback < Rack::UserFeedback
3
- def initialize(app)
4
- warn '[DEPRECATION] Honeybadger::UserFeedback is deprecated in 2.0. Use Honeybadger::Rack::UserFeedback.'
5
- super
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- module Honeybadger
2
- class UserInformer < Rack::UserInformer
3
- def initialize(app)
4
- warn '[DEPRECATION] Honeybadger::UserInformer is deprecated in 2.0. Use Honeybadger::Rack::UserInformer.'
5
- super
6
- end
7
- end
8
- end
@@ -1,69 +0,0 @@
1
- require 'net/http'
2
- require 'uri'
3
-
4
- # Capistrano tasks for notifying Honeybadger of deploys
5
- module HoneybadgerTasks
6
-
7
- # Public: Alerts Honeybadger of a deploy.
8
- #
9
- # opts - Data about the deploy that is set to Honeybadger
10
- # :api_key - Api key of you Honeybadger application
11
- # :environment - Environment of the deploy (production, staging)
12
- # :revision - The given revision/sha that is being deployed
13
- # :repository - Address of your repository to help with code lookups
14
- # :local_username - Who is deploying
15
- #
16
- # Returns true or false
17
- def self.deploy(opts = {})
18
- api_key = opts.delete(:api_key) || Honeybadger.configuration.api_key
19
- unless api_key =~ /\S/
20
- $stderr.puts "I don't seem to be configured with an API key. Please check your configuration."
21
- return false
22
- end
23
-
24
- unless opts[:environment] =~ /\S/
25
- $stderr.puts "I don't know to which environment you are deploying (use the TO=production option)."
26
- return false
27
- end
28
-
29
- dry_run = opts.delete(:dry_run)
30
- params = {}
31
- opts.each {|k,v| params["deploy[#{k}]"] = v }
32
-
33
- host = Honeybadger.configuration.host || 'api.honeybadger.io'
34
- port = Honeybadger.configuration.port
35
-
36
- proxy = Net::HTTP.Proxy(Honeybadger.configuration.proxy_host,
37
- Honeybadger.configuration.proxy_port,
38
- Honeybadger.configuration.proxy_user,
39
- Honeybadger.configuration.proxy_pass)
40
- http = proxy.new(host, port)
41
-
42
- # Handle Security
43
- if Honeybadger.configuration.secure?
44
- http.use_ssl = true
45
- http.ca_file = Honeybadger.configuration.ca_bundle_path
46
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
47
- end
48
-
49
- post = Net::HTTP::Post.new("/v1/deploys")
50
- post.set_form_data(params)
51
- post['X-API-Key'] = api_key
52
-
53
- if dry_run
54
- puts http.inspect, params.inspect
55
- return true
56
- else
57
- response = http.request(post)
58
-
59
- if Net::HTTPSuccess === response
60
- puts "Successfully recorded deployment"
61
- return true
62
- else
63
- $stderr.puts "Error recording deployment: #{response.class} -- #{response.body || 'no response'}"
64
- return false
65
- end
66
- end
67
- end
68
- end
69
-
@@ -1,99 +0,0 @@
1
- require 'rails/generators'
2
-
3
- class HoneybadgerGenerator < Rails::Generators::Base
4
- class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Honeybadger API key"
5
- class_option :heroku, :type => :boolean, :desc => "Use the Heroku addon to provide your Honeybadger API key"
6
- class_option :app, :aliases => "-a", :type => :string, :desc => "Your Heroku app name (only required if deploying to >1 Heroku app)"
7
-
8
- def self.source_root
9
- @_honeybadger_source_root ||= File.expand_path("../../../../../generators/honeybadger/templates", __FILE__)
10
- end
11
-
12
- def install
13
- ensure_api_key_was_configured
14
- ensure_plugin_is_not_present
15
- append_capistrano_hook
16
- generate_initializer unless api_key_configured?
17
- determine_api_key if heroku?
18
- test_honeybadger
19
- end
20
-
21
- private
22
-
23
- def ensure_api_key_was_configured
24
- if !options[:api_key] && !options[:heroku] && !api_key_configured?
25
- puts "Must pass --api-key or --heroku or create config/initializers/honeybadger.rb"
26
- exit
27
- end
28
- end
29
-
30
- def ensure_plugin_is_not_present
31
- if plugin_is_present?
32
- puts "You must first remove the honeybadger plugin. Please run: script/plugin remove honeybadger"
33
- exit
34
- end
35
- end
36
-
37
- def append_capistrano_hook
38
- if File.exists?('config/deploy.rb') && File.exists?('Capfile')
39
- append_file('Capfile', <<-HOOK)
40
-
41
- require 'honeybadger/capistrano'
42
- HOOK
43
- end
44
- end
45
-
46
- def api_key_expression
47
- s = if options[:api_key]
48
- "'#{options[:api_key]}'"
49
- elsif options[:heroku]
50
- "ENV['HONEYBADGER_API_KEY']"
51
- end
52
- end
53
-
54
- def generate_initializer
55
- template 'initializer.rb', 'config/initializers/honeybadger.rb'
56
- end
57
-
58
- def determine_api_key
59
- puts "Attempting to determine your API Key from Heroku..."
60
- ENV['HONEYBADGER_API_KEY'] = heroku_api_key
61
- if ENV['HONEYBADGER_API_KEY'] =~ /\S/
62
- puts "... Done."
63
- puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
64
- else
65
- puts "... Failed."
66
- puts "WARNING: We were unable to detect the Honeybadger API Key from your Heroku environment."
67
- puts "Your Heroku application environment may not be configured correctly."
68
- puts "Have you configured multiple Heroku apps? Try using the '--app [app name]' flag." unless options[:app]
69
- exit 1
70
- end
71
- end
72
-
73
- def heroku_var(var, app_name = nil)
74
- app = app_name ? "--app #{app_name}" : ''
75
- Bundler.with_clean_env { `heroku config:get #{var} #{app}` }
76
- end
77
-
78
- def heroku_api_key
79
- heroku_var("HONEYBADGER_API_KEY", options[:app]).split.find {|x| x =~ /\S/ }
80
- end
81
-
82
- def heroku?
83
- options[:heroku] ||
84
- system("grep HONEYBADGER_API_KEY config/initializers/honeybadger.rb") ||
85
- system("grep HONEYBADGER_API_KEY config/environment.rb")
86
- end
87
-
88
- def api_key_configured?
89
- File.exists?('config/initializers/honeybadger.rb')
90
- end
91
-
92
- def test_honeybadger
93
- puts run("rake honeybadger:test --trace")
94
- end
95
-
96
- def plugin_is_present?
97
- File.exists?('vendor/plugins/honeybadger')
98
- end
99
- end
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'honeybadger/rails'
data/resources/README.md DELETED
@@ -1,34 +0,0 @@
1
- Honeybadger Resources
2
- ==================
3
-
4
- Honeybadger has an SSL mode available to paying plans. SSL Certificate Authority (CA) certificates are not kept current by default on many environments. When CA certs are stale, Honeybadger cannot verify Honeybadger's production SSL cert and error reports fail. To avoid this, we now package local CA certs. The production of these certs is detailed here.
5
-
6
- Building ca-bundle.crt
7
- ----------------------
8
-
9
- From https://gist.github.com/996292.
10
-
11
- If you want to use curl or net-http/open-uri to access https resources, you will often (always?) get an error, because they don't have the large number of root certificates installed that web browsers have.
12
-
13
- You can manually install the root certs, but first you have to get them from somewhere. [This article](http://notetoself.vrensk.com/2008/09/verified-https-in-ruby/) gives a nice description of how to do that. The [source of the cert files](http://curl.haxx.se/ca/cacert.pem) it points to is hosted by the curl project, who kindly provide it in the .pem format.
14
-
15
- **problem:** Sadly, ironically, and comically, it's not possible to access that file via https! Luckily, the awesome curl project does provide us with the script that they use to produce the file, so we can do it securely ourselves. Here's how.
16
-
17
- 1. `git clone https://github.com/bagder/curl.git`
18
- 2. `cd curl/lib`
19
- 3. edit `mk-ca-bundle.pl` and change:
20
-
21
- ```perl
22
- my $url = 'http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1';
23
- ```
24
-
25
- to
26
-
27
- ```perl
28
- my $url = 'https://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1';
29
- ```
30
-
31
- (change `http` to `https`)
32
- 4. `./mk-ca-bundle.pl`
33
-
34
- Ta da!
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'logger'
4
- require 'fileutils'
5
-
6
- RAILS_ENV = "production"
7
- RAILS_ROOT = FileUtils.pwd
8
- RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
9
-
10
- $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
11
- require 'honeybadger'
12
- require 'rails/init'
13
-
14
- fail "Please supply an API Key as the first argument" if ARGV.empty?
15
-
16
- host = ARGV[1]
17
- host ||= "api.honeybadger.io"
18
-
19
- secure = (ARGV[2] == "secure")
20
-
21
- exception = begin
22
- raise "Testing honeybadger notifier with secure = #{secure}. If you can see this, it works."
23
- rescue => foo
24
- foo
25
- end
26
-
27
- Honeybadger.configure do |config|
28
- config.secure = secure
29
- config.host = host
30
- config.api_key = ARGV.first
31
- end
32
- puts "Configuration:"
33
- Honeybadger.configuration.to_hash.each do |key, value|
34
- puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
35
- end
36
- puts "Sending #{secure ? "" : "in"}secure notification to project with key #{ARGV.first}"
37
- Honeybadger.notify(exception)
38
-
@@ -1,32 +0,0 @@
1
- require 'allocation_stats'
2
- require 'honeybadger'
3
- require 'benchmark'
4
- require 'sham_rack'
5
-
6
- ShamRack.at('api.honeybadger.io', 443).stub.tap do |app|
7
- app.register_resource('/v1/notices/', %({"id":"123456789"}), "application/json")
8
- app.register_resource('/v1/ping/', %({"features":{"notices":true,"feedback":true}, "limit":null}), "application/json")
9
- end
10
-
11
- group_by = if ENV['GROUP']
12
- ENV['GROUP'].split(',').lazy.map(&:strip).map(&:to_sym).freeze
13
- else
14
- [:sourcefile, :sourceline, :class].freeze
15
- end
16
-
17
- puts Benchmark.measure {
18
- stats = AllocationStats.trace do
19
- Honeybadger.configure do |config|
20
- config.api_key = 'badgers'
21
- config.environment_name = 'production'
22
- config.development_environments = []
23
- end
24
-
25
- 1000.times do
26
- Honeybadger.notify(error_class: 'AllocationStats', error_message: 'Profiling Honeybadger -- this should never actually be reported.')
27
- end
28
- end
29
-
30
- puts stats.allocations(alias_paths: true).group_by(*group_by).to_text
31
- puts "\n\n"
32
- }
@@ -1,242 +0,0 @@
1
- require 'spec_helper'
2
- require 'stringio'
3
-
4
- describe Honeybadger::Backtrace do
5
- it "parses a backtrace into lines" do
6
- array = [
7
- "app/models/user.rb:13:in `magic'",
8
- "app/controllers/users_controller.rb:8:in `index'"
9
- ]
10
-
11
- backtrace = Honeybadger::Backtrace.parse(array)
12
-
13
- line = backtrace.lines.first
14
- expect(line.number).to eq '13'
15
- expect(line.file).to eq 'app/models/user.rb'
16
- expect(line.method).to eq 'magic'
17
-
18
- line = backtrace.lines.last
19
- expect(line.number).to eq '8'
20
- expect(line.file).to eq 'app/controllers/users_controller.rb'
21
- expect(line.method).to eq 'index'
22
- end
23
-
24
- it "parses a windows backtrace into lines" do
25
- array = [
26
- "C:/Program Files/Server/app/models/user.rb:13:in `magic'",
27
- "C:/Program Files/Server/app/controllers/users_controller.rb:8:in `index'"
28
- ]
29
-
30
- backtrace = Honeybadger::Backtrace.parse(array)
31
-
32
- line = backtrace.lines.first
33
- expect(line.number).to eq '13'
34
- expect(line.file).to eq 'C:/Program Files/Server/app/models/user.rb'
35
- expect(line.method).to eq 'magic'
36
-
37
- line = backtrace.lines.last
38
- expect(line.number).to eq '8'
39
- expect(line.file).to eq 'C:/Program Files/Server/app/controllers/users_controller.rb'
40
- expect(line.method).to eq 'index'
41
- end
42
-
43
- it "is equal with equal lines" do
44
- one = build_backtrace_array
45
- two = one.dup
46
-
47
- expect(Honeybadger::Backtrace.parse(one)).to eq Honeybadger::Backtrace.parse(two)
48
- end
49
-
50
- it "parses massive one-line exceptions into multiple lines" do
51
- original_backtrace = Honeybadger::Backtrace.
52
- parse(["one:1:in `one'\n two:2:in `two'\n three:3:in `three`"])
53
- expected_backtrace = Honeybadger::Backtrace.
54
- parse(["one:1:in `one'", "two:2:in `two'", "three:3:in `three`"])
55
-
56
- expect(expected_backtrace).to eq original_backtrace
57
- end
58
-
59
- context "when source file exists" do
60
- before(:each) do
61
- source = <<-RUBY
62
- $:<<'lib'
63
- require 'honeybadger'
64
-
65
- begin
66
- raise StandardError
67
- rescue => e
68
- puts Honeybadger::Notice.new(exception: e).backtrace.to_json
69
- end
70
- RUBY
71
-
72
- array = [
73
- "app/models/user.rb:2:in `magic'",
74
- "app/concerns/authenticated_controller.rb:4:in `authorize'",
75
- "app/controllers/users_controller.rb:8:in `index'"
76
- ]
77
-
78
- ['app/models/user.rb', 'app/concerns/authenticated_controller.rb', 'app/controllers/users_controller.rb'].each do |file|
79
- File.should_receive(:exists?).with(file).and_return true
80
- File.should_receive(:open).with(file).and_yield StringIO.new(source)
81
- end
82
-
83
- @backtrace = Honeybadger::Backtrace.parse(array)
84
- end
85
-
86
- it "includes a snippet from the source file for each line of the backtrace" do
87
- expect(@backtrace.lines[0].source.keys.size).to eq(4)
88
- expect(@backtrace.lines[0].source[1]).to match(/\$:<</)
89
- expect(@backtrace.lines[0].source[2]).to match(/require/)
90
- expect(@backtrace.lines[0].source[3]).to match(/\n/)
91
- expect(@backtrace.lines[0].source[4]).to match(/begin/)
92
-
93
- expect(@backtrace.lines[1].source.keys.size).to eq(5)
94
- expect(@backtrace.lines[1].source[2]).to match(/require/)
95
- expect(@backtrace.lines[1].source[3]).to match(/\n/)
96
- expect(@backtrace.lines[1].source[4]).to match(/begin/)
97
- expect(@backtrace.lines[1].source[5]).to match(/StandardError/)
98
- expect(@backtrace.lines[1].source[6]).to match(/rescue/)
99
-
100
- expect(@backtrace.lines[2].source.keys.size).to eq(3)
101
- expect(@backtrace.lines[2].source[6]).to match(/rescue/)
102
- expect(@backtrace.lines[2].source[7]).to match(/Honeybadger/)
103
- expect(@backtrace.lines[2].source[8]).to match(/end/)
104
- end
105
- end
106
-
107
- it "fails gracefully when looking up snippet and file doesn't exist" do
108
- array = [
109
- "app/models/user.rb:13:in `magic'",
110
- "app/controllers/users_controller.rb:8:in `index'"
111
- ]
112
-
113
- backtrace = Honeybadger::Backtrace.parse(array)
114
-
115
- expect(backtrace.lines[0].source).to be_empty
116
- expect(backtrace.lines[1].source).to be_empty
117
- end
118
-
119
- it "has an empty application trace by default" do
120
- backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
121
- expect(backtrace.application_lines).to be_empty
122
- end
123
-
124
- context "with a project root" do
125
- before(:each) do
126
- @project_root = '/some/path'
127
- Honeybadger.configure {|config| config.project_root = @project_root }
128
-
129
- @backtrace_with_root = Honeybadger::Backtrace.parse(
130
- ["#{@project_root}/app/models/user.rb:7:in `latest'",
131
- "#{@project_root}/app/controllers/users_controller.rb:13:in `index'",
132
- "#{@project_root}/vendor/plugins/foo/bar.rb:42:in `baz'",
133
- "/lib/something.rb:41:in `open'"],
134
- :filters => default_filters)
135
- @backtrace_without_root = Honeybadger::Backtrace.parse(
136
- ["[PROJECT_ROOT]/app/models/user.rb:7:in `latest'",
137
- "[PROJECT_ROOT]/app/controllers/users_controller.rb:13:in `index'",
138
- "[PROJECT_ROOT]/vendor/plugins/foo/bar.rb:42:in `baz'",
139
- "/lib/something.rb:41:in `open'"])
140
- end
141
-
142
- it "filters out the project root" do
143
- expect(@backtrace_without_root).to eq @backtrace_with_root
144
- end
145
-
146
- it "has an application trace" do
147
- expect(@backtrace_without_root.application_lines).to eq @backtrace_without_root.lines[0..1]
148
- end
149
-
150
- it "filters ./vendor from application trace" do
151
- expect(@backtrace_without_root.application_lines).not_to include(@backtrace_without_root.lines[2])
152
- end
153
- end
154
-
155
- context "with a project root equals to a part of file name" do
156
- before(:each) do
157
- # Heroku-like
158
- @project_root = '/app'
159
- Honeybadger.configure {|config| config.project_root = @project_root }
160
- end
161
-
162
- it "filters out the project root" do
163
- backtrace_with_root = Honeybadger::Backtrace.parse(
164
- ["#{@project_root}/app/models/user.rb:7:in `latest'",
165
- "#{@project_root}/app/controllers/users_controller.rb:13:in `index'",
166
- "/lib/something.rb:41:in `open'"],
167
- :filters => default_filters)
168
- backtrace_without_root = Honeybadger::Backtrace.parse(
169
- ["[PROJECT_ROOT]/app/models/user.rb:7:in `latest'",
170
- "[PROJECT_ROOT]/app/controllers/users_controller.rb:13:in `index'",
171
- "/lib/something.rb:41:in `open'"])
172
-
173
- expect(backtrace_without_root).to eq backtrace_with_root
174
- end
175
- end
176
-
177
- context "with a blank project root" do
178
- before(:each) do
179
- Honeybadger.configure {|config| config.project_root = '' }
180
- end
181
-
182
- it "does not filter line numbers with respect to any project root" do
183
- backtrace = ["/app/models/user.rb:7:in `latest'",
184
- "/app/controllers/users_controller.rb:13:in `index'",
185
- "/lib/something.rb:41:in `open'"]
186
-
187
- backtrace_with_root =
188
- Honeybadger::Backtrace.parse(backtrace, :filters => default_filters)
189
-
190
- backtrace_without_root =
191
- Honeybadger::Backtrace.parse(backtrace)
192
-
193
- expect(backtrace_without_root).to eq backtrace_with_root
194
- end
195
- end
196
-
197
- it "removes notifier trace" do
198
- inside_notifier = ['lib/honeybadger.rb:13:in `voodoo`']
199
- outside_notifier = ['users_controller:8:in `index`']
200
-
201
- without_inside = Honeybadger::Backtrace.parse(outside_notifier)
202
- with_inside = Honeybadger::Backtrace.parse(inside_notifier + outside_notifier,
203
- :filters => default_filters)
204
-
205
- expect(without_inside).to eq with_inside
206
- end
207
-
208
- it "runs filters on the backtrace" do
209
- filters = [lambda { |line| line.sub('foo', 'bar') }]
210
- input = Honeybadger::Backtrace.parse(["foo:13:in `one'", "baz:14:in `two'"],
211
- :filters => filters)
212
- expected = Honeybadger::Backtrace.parse(["bar:13:in `one'", "baz:14:in `two'"])
213
- expect(expected).to eq input
214
- end
215
-
216
- it "aliases #to_ary as #to_a" do
217
- backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
218
-
219
- expect(backtrace.to_a).to eq backtrace.to_ary
220
- end
221
-
222
- it "generates json from to_array template" do
223
- backtrace = Honeybadger::Backtrace.parse(build_backtrace_array)
224
- array = [{'foo' => 'bar'}]
225
- backtrace.should_receive(:to_ary).once.and_return(array)
226
- json = backtrace.to_json
227
-
228
- payload = nil
229
- expect { payload = JSON.parse(json) }.not_to raise_error
230
-
231
- expect(payload).to eq array
232
- end
233
-
234
- def build_backtrace_array
235
- ["app/models/user.rb:13:in `magic'",
236
- "app/controllers/users_controller.rb:8:in `index'"]
237
- end
238
-
239
- def default_filters
240
- Honeybadger::Configuration::DEFAULT_BACKTRACE_FILTERS
241
- end
242
- end