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,82 +0,0 @@
1
- require 'spec_helper'
2
- require 'honeybadger/monitor'
3
-
4
- begin
5
- require 'delayed_job'
6
- require 'honeybadger/integrations/delayed_job/plugin'
7
- DELAYED_JOB_INSTALLED = true
8
- rescue LoadError
9
- DELAYED_JOB_INSTALLED = false
10
- nil
11
- end
12
-
13
- if DELAYED_JOB_INSTALLED
14
- # Prepend the load path with delayed_job's spec directory so that we can take
15
- # advantage of their test backend:
16
- # https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb
17
- $:.unshift(File.join(Gem::Specification.find_by_name('delayed_job').full_gem_path, 'spec'))
18
- Delayed::Worker.backend = :test
19
-
20
- class ExceptionTester
21
- def null_method
22
- end
23
-
24
- def will_raise
25
- raise "raised from will_raise"
26
- end
27
- end
28
-
29
- describe "DelayedJob integration" do
30
- let(:worker) { @worker }
31
-
32
- before(:all) do
33
- Delayed::Worker.plugins = [Honeybadger::Integrations::DelayedJob::Plugin]
34
- @worker = Delayed::Worker.new
35
- end
36
-
37
- after { Delayed::Job.delete_all }
38
-
39
- context "when a method is delayed" do
40
- let(:method_name) { :null_method }
41
-
42
- before { ExceptionTester.new.delay.send(method_name) }
43
-
44
- specify { expect(Delayed::Job.count).to eq 1 }
45
-
46
- it "queues a new trace" do
47
- trace_id = nil
48
- Honeybadger::Monitor.worker.should_receive(:queue_trace).once.and_return do
49
- # This ensures that Honeybadger::Monitor.worker.trace is not nil when
50
- # it's queued from the worker. There may still be an edge case where
51
- # that's possible. (see #84)
52
- trace_id = Thread.current[:hb_trace_id]
53
- end
54
- worker.work_off
55
- expect(trace_id).not_to be_nil
56
- end
57
-
58
- context "and an exception occurs" do
59
- let(:method_name) { :will_raise }
60
-
61
- after { worker.work_off }
62
-
63
- it "notifies Honeybadger" do
64
- Honeybadger.should_receive(:notify_or_ignore).once
65
- end
66
- end
67
-
68
- context "and a threshold is set" do
69
- let(:method_name) { :will_raise }
70
-
71
- before { ::Honeybadger.configuration.delayed_job_attempt_threshold = 2 }
72
- after { ::Honeybadger.configuration.delayed_job_attempt_threshold = 0 }
73
-
74
- it "does not notify Honeybadger on first occurence" do
75
- Honeybadger.should_not_receive(:notify_or_ignore)
76
-
77
- worker.work_off
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Local variables integration" do
4
- before do
5
- Honeybadger.configuration.send_local_variables = config_enabled
6
- Honeybadger::Dependency.inject!
7
- end
8
-
9
- subject { Exception.new }
10
-
11
- context "when binding_of_caller isn't installed", :unless => defined?(::BindingOfCaller) do
12
- let(:config_enabled) { true }
13
- it { should_not respond_to :__honeybadger_bindings_stack }
14
- end
15
-
16
- context "when binding_of_caller is installed", :if => defined?(::BindingOfCaller) do
17
- context "and disabled by configuration" do
18
- let(:config_enabled) { false }
19
- it { should_not respond_to :__honeybadger_bindings_stack }
20
- end
21
-
22
- context "and enabled by configuration" do
23
- let(:config_enabled) { true }
24
-
25
- it { should respond_to :__honeybadger_bindings_stack }
26
-
27
- describe "#set_backtrace" do
28
- context "call stack does not match current file" do
29
- it "changes the bindings stack" do
30
- expect { subject.set_backtrace(['foo.rb:1']) }.to change(subject, :__honeybadger_bindings_stack).from([])
31
- end
32
- end
33
-
34
- context "call stack includes current file" do
35
- before do
36
- subject.stub(:caller).and_return(["#{File.expand_path('../../../../lib/honeybadger/integrations/local_variables.rb', __FILE__)}:1"])
37
- end
38
-
39
- it "does not change the bindings stack" do
40
- expect { subject.set_backtrace(['foo.rb:1']) }.not_to change(subject, :__honeybadger_bindings_stack).from([])
41
- end
42
- end
43
-
44
- context "call stack includes a non-matching line" do
45
- before do
46
- subject.stub(:caller).and_return(['(foo)'])
47
- end
48
-
49
- it "skips the non-matching line" do
50
- expect { subject.set_backtrace(['foo.rb:1']) }.not_to raise_error
51
- end
52
-
53
- it "changes the bindings stack" do
54
- expect { subject.set_backtrace(['foo.rb:1']) }.to change(subject, :__honeybadger_bindings_stack).from([])
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- begin
4
- require 'active_support/notifications'
5
- rescue LoadError
6
- nil
7
- end
8
-
9
- describe "Net::HTTP Dependency" do
10
- before do
11
- Honeybadger::Dependency.reset!
12
- end
13
-
14
- if defined?(ActiveSupport::Notifications)
15
- context "when active support notifications are installed" do
16
- it "installs instrumentation" do
17
- Honeybadger::Dependency.inject!
18
- expect(Net::HTTP.instance_method(:request)).to eq Net::HTTP.instance_method(:request_with_honeybadger)
19
- end
20
- end
21
- else
22
- context "when active support notifications are not installed" do
23
- it "does not install instrumentation" do
24
- Honeybadger::Dependency.inject!
25
- expect(Net::HTTP.instance_methods).not_to include(:request_with_honeybadger)
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Passenger integration" do
4
- before do
5
- Honeybadger::Dependency.reset!
6
- end
7
-
8
- context "when passenger is not installed" do
9
- it "fails quietly" do
10
- expect { Honeybadger::Dependency.inject! }.not_to raise_error
11
- end
12
- end
13
-
14
- context "when passenger is installed" do
15
- let(:shim) { double('PhusionPassenger') }
16
-
17
- before do
18
- Object.const_set(:PhusionPassenger, shim)
19
- end
20
- after { Object.send(:remove_const, :PhusionPassenger) }
21
-
22
- it "installs passenger hooks" do
23
- shim.should_receive(:on_event).with(:starting_worker_process)
24
- shim.should_receive(:on_event).with(:stopping_worker_process)
25
- Honeybadger::Dependency.inject!
26
- end
27
- end
28
- end
29
-
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sidekiq Dependency" do
4
- before do
5
- Honeybadger::Dependency.reset!
6
- end
7
-
8
- context "when sidekiq is not installed" do
9
- it "fails quietly" do
10
- expect { Honeybadger::Dependency.inject! }.not_to raise_error
11
- end
12
- end
13
-
14
- context "when sidekiq is installed" do
15
- let(:shim) do
16
- Class.new do
17
- def self.configure_server
18
- end
19
- end
20
- end
21
-
22
- let(:config) { double('config', :error_handlers => []) }
23
- let(:chain) { double('chain', :add => true) }
24
-
25
- before do
26
- Object.const_set(:Sidekiq, shim)
27
- ::Sidekiq.stub(:configure_server).and_yield(config)
28
- config.stub(:server_middleware).and_yield(chain)
29
- end
30
-
31
- after { Object.send(:remove_const, :Sidekiq) }
32
-
33
- context "when version is less than 3" do
34
- before do
35
- ::Sidekiq.const_set(:VERSION, '2.17.7')
36
- end
37
-
38
- it "adds the server middleware" do
39
- chain.should_receive(:add).with(Honeybadger::Integrations::Sidekiq::Middleware)
40
- Honeybadger::Dependency.inject!
41
- end
42
-
43
- it "doesn't add the error handler" do
44
- Honeybadger::Dependency.inject!
45
- expect(config.error_handlers).to be_empty
46
- end
47
- end
48
-
49
- context "when version is 3 or greater" do
50
- before do
51
- ::Sidekiq.const_set(:VERSION, '3.0.0')
52
- end
53
-
54
- it "adds the error handler" do
55
- Honeybadger::Dependency.inject!
56
- expect(config.error_handlers).not_to be_empty
57
- end
58
- end
59
- end
60
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Thor Dependency" do
4
- before do
5
- Honeybadger::Dependency.reset!
6
- end
7
-
8
- context "when thor is not installed" do
9
- it "fails quietly" do
10
- expect { Honeybadger::Dependency.inject! }.not_to raise_error
11
- end
12
- end
13
-
14
- context "when thor is installed" do
15
- let(:shim) do
16
- Class.new do
17
- def self.no_commands
18
- end
19
- end
20
- end
21
-
22
- before do
23
- Object.const_set(:Thor, shim)
24
- end
25
- after { Object.send(:remove_const, :Thor) }
26
-
27
- it "includes integration module into Thor" do
28
- shim.should_receive(:send).with(:include, Honeybadger::Integrations::Thor)
29
- Honeybadger::Dependency.inject!
30
- end
31
- end
32
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Unicorn integration" do
4
- before do
5
- Honeybadger::Dependency.reset!
6
- end
7
-
8
- context "when unicorn is not installed" do
9
- it "fails quietly" do
10
- expect { Honeybadger::Dependency.inject! }.not_to raise_error
11
- end
12
- end
13
-
14
- context "when unicorn is installed" do
15
- let(:shim) {
16
- Class.new {
17
- def init_worker_process(worker)
18
- 'foo'
19
- end
20
- }
21
- }
22
-
23
- before do
24
- Object.const_set(:Unicorn, Module.new)
25
- Unicorn.const_set(:HttpServer, shim)
26
- end
27
- after { Object.send(:remove_const, :Unicorn) }
28
-
29
- it "logs installation" do
30
- Honeybadger.should_receive(:write_verbose_log).with(/Unicorn/)
31
- Honeybadger::Dependency.inject!
32
- end
33
-
34
- it "installs unicorn hooks" do
35
- Honeybadger::Dependency.inject!
36
- Honeybadger::Monitor.worker.should_receive(:fork)
37
- expect(shim.new.init_worker_process(double('worker'))).to eq 'foo'
38
- end
39
- end
40
- end
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Honeybadger do
4
- def send_notice
5
- Honeybadger.sender.send_to_honeybadger('data')
6
- end
7
-
8
- def stub_verbose_log
9
- Honeybadger.stub(:write_verbose_log)
10
- end
11
-
12
- def configure
13
- Honeybadger.configure { |config| }
14
- end
15
-
16
- it "reports that notifier is ready when configured" do
17
- stub_verbose_log
18
- Honeybadger.should_receive(:write_verbose_log).with(/Notifier (.*) ready/, anything)
19
- configure
20
- end
21
-
22
- it "does not report that notifier is ready when internally configured" do
23
- stub_verbose_log
24
- Honeybadger.should_not_receive(:write_verbose_log)
25
- Honeybadger.configure(true) { |config| }
26
- end
27
-
28
- it "prints environment info on a failed notification without a body" do
29
- reset_config
30
- stub_verbose_log
31
- stub_http(:response => Net::HTTPError, :body => nil)
32
- Honeybadger.should_receive(:write_verbose_log).with(/Environment Info:/)
33
- Honeybadger.should_not_receive(:write_verbose_log).with(/Response from Honeybadger:/, anything)
34
- send_notice
35
- end
36
-
37
- it "prints environment info and response on a success with a body" do
38
- reset_config
39
- stub_verbose_log
40
- stub_http
41
- Honeybadger.should_receive(:write_verbose_log).with(/Environment Info:/)
42
- Honeybadger.should_receive(:write_verbose_log).with(/Response from Honeybadger:/)
43
- send_notice
44
- end
45
-
46
- it "prints environment info and response on a failure with a body" do
47
- reset_config
48
- stub_verbose_log
49
- stub_http(:response => Net::HTTPError)
50
- Honeybadger.should_receive(:write_verbose_log).with(/Environment Info:/)
51
- Honeybadger.should_receive(:write_verbose_log).with(/Response from Honeybadger:/)
52
- send_notice
53
- end
54
-
55
- context "429 error response" do
56
- let(:failure_class) do
57
- if RUBY_VERSION !~ /^1/
58
- Net::HTTPTooManyRequests
59
- else
60
- Net::HTTPClientError
61
- end
62
- end
63
-
64
- let(:http) { stub_http(:response => failure_class.new('1.2', '429', 'Peace out'), :body => '{"error":"something went wrong"}') }
65
-
66
- before do
67
- reset_config
68
- stub_verbose_log
69
- end
70
-
71
- it "logs the response" do
72
- http.should_receive(:post).with(Honeybadger::Sender::NOTICES_URI, kind_of(String), kind_of(Hash))
73
- Honeybadger.should_receive(:write_verbose_log).with(/Failure: #{failure_class.name}/, :error)
74
- Honeybadger.should_receive(:write_verbose_log).with(/Environment Info:/)
75
- Honeybadger.should_receive(:write_verbose_log).with(/something went wrong/)
76
- Honeybadger.notify(RuntimeError.new('oops!'))
77
- end
78
- end
79
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
- require 'honeybadger/monitor'
3
-
4
- describe Honeybadger::Monitor::Trace do
5
- describe "::instrument" do
6
- before do
7
- Honeybadger::Monitor::Trace.stub(:generate_secure_id).and_return(:foo)
8
- end
9
-
10
- it "creates a new trace" do
11
- Honeybadger::Monitor::Trace.should_receive(:new).and_call_original
12
- described_class.instrument('testing', {}){}
13
- end
14
-
15
- it "temporarily stores trace id in thread local" do
16
- described_class.instrument('testing', {}) do
17
- expect(Thread.current[:hb_trace_id]).to eq :foo
18
- end
19
-
20
- expect(Thread.current[:hb_trace_id]).to be_nil
21
- end
22
-
23
- it "stores the trace on the worker's pending traces" do
24
- described_class.instrument('testing', {}) do
25
- expect(Honeybadger::Monitor.worker.pending_traces[:foo]).to be_a Honeybadger::Monitor::Trace
26
- end
27
-
28
- expect(Honeybadger::Monitor.worker.pending_traces[:foo]).to be_nil
29
- end
30
- end
31
- end
32
-
33
- begin
34
- require 'active_support/notifications'
35
- require 'active_record'
36
-
37
- describe Honeybadger::Monitor::TraceCleaner::ActiveRecord do
38
- let(:event) do
39
- ::ActiveSupport::Notifications::Event.new(
40
- 'sql.active_record', # name
41
- now = Time.now.to_f, # start
42
- now+0.2, # ending
43
- '1', # transaction_id
44
- { # payload
45
- :name => nil,
46
- :sql => '',
47
- :binds => [],
48
- :connection_id => 123
49
- }
50
- )
51
- end
52
-
53
- before do
54
- ::ActiveRecord::Base.stub(:connection_pool).and_return(double(:spec => double(:config => {})))
55
- end
56
-
57
- # This will fail if the configuration is accessed through
58
- # `ActiveRecord::Base.connection_config` in rails < 3.1.
59
- it "safely accesses connection configuration" do
60
- expect { described_class.new(event).to_s }.not_to raise_error
61
- end
62
- end
63
- rescue LoadError
64
- nil
65
- end