honeybadger 1.15.2 → 1.15.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 309a76fdbd5d01c3af0c928f74e0bf985f004d86
4
- data.tar.gz: 301301ac6dfdf741c54903026c84635d4a74b781
3
+ metadata.gz: 9cfe3439d58b7af28a565d2de4933b569739de24
4
+ data.tar.gz: bbce3f75341c717bb1509ef572e13d5383b7e156
5
5
  SHA512:
6
- metadata.gz: 1316f55be220bdbe64b32093d4687fe15b15fd907886d59bfda72805306010c7a7fcf448a240c211a1e94335a9508152c34134f127cdc31410cd2a57d1c28565
7
- data.tar.gz: 3e3042b01a08ed472b1e20687d66bf683bd2ea4e44979b1c94880828cf7732b07bfd2b0e1ea12f22f3875196d5c1b7fe4979f503483a7d23150bae2a0a20eb2b
6
+ metadata.gz: 4e26c85da0f200e09d0d89a19cef8d49d01bab91ef6a430257c4b39987636b29b927cdda9a1d15d880507383309b62b1b1ad01fa8a391620273db44542fb3a6b
7
+ data.tar.gz: 43a4170cc003e0c4f1191255734bb3437c632ce30c708b12b8031fcf323927d1fcdd6825d26bf49001acc5cc41a02545a52a3fc6313567e844fa55bd46cb0e3c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- ## Honeybadger 1.15.1 ##
1
+ ## Honeybadger 1.15.3 ##
2
+
3
+ * Send User-Agent header
4
+
5
+ *Joshua Wood*
6
+
7
+ * Fix a bug where metrics were not reported for Passenger processes.
8
+
9
+ *Joshua Wood*
10
+
11
+ ## Honeybadger 1.15.2 ##
2
12
 
3
13
  * Fix bug where honeybadger/monitor wasn't included in non-Rails apps, even
4
14
  though certain other integrations depend on it.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeybadger (1.15.2)
4
+ honeybadger (1.15.3)
5
5
  json
6
6
 
7
7
  GEM
data/honeybadger.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'honeybadger'
7
- s.version = '1.15.2'
8
- s.date = '2014-06-20'
7
+ s.version = '1.15.3'
8
+ s.date = '2014-06-21'
9
9
 
10
10
  s.summary = 'Error reports you can be happy about.'
11
11
  s.description = 'Make managing application errors a more pleasant experience.'
@@ -100,6 +100,7 @@ Gem::Specification.new do |s|
100
100
  lib/honeybadger/integrations/delayed_job.rb
101
101
  lib/honeybadger/integrations/delayed_job/plugin.rb
102
102
  lib/honeybadger/integrations/net_http.rb
103
+ lib/honeybadger/integrations/passenger.rb
103
104
  lib/honeybadger/integrations/sidekiq.rb
104
105
  lib/honeybadger/integrations/thor.rb
105
106
  lib/honeybadger/monitor.rb
@@ -140,6 +141,7 @@ Gem::Specification.new do |s|
140
141
  spec/honeybadger/exception_extensions_spec.rb
141
142
  spec/honeybadger/integrations/delayed_job_spec.rb
142
143
  spec/honeybadger/integrations/net_http_spec.rb
144
+ spec/honeybadger/integrations/passenger_spec.rb
143
145
  spec/honeybadger/integrations/sidekiq_spec.rb
144
146
  spec/honeybadger/integrations/thor_spec.rb
145
147
  spec/honeybadger/logger_spec.rb
data/lib/honeybadger.rb CHANGED
@@ -20,13 +20,14 @@ require 'honeybadger/railtie' if defined?(Rails::Railtie)
20
20
  require 'honeybadger/monitor'
21
21
 
22
22
  module Honeybadger
23
- VERSION = '1.15.2'
24
- LOG_PREFIX = "** [Honeybadger] "
23
+ VERSION = '1.15.3'.freeze
24
+ LOG_PREFIX = "** [Honeybadger] ".freeze
25
25
 
26
26
  HEADERS = {
27
27
  'Content-type' => 'application/json',
28
- 'Accept' => 'text/json, application/json'
29
- }
28
+ 'Accept' => 'text/json, application/json',
29
+ 'User-Agent' => "HB-Ruby #{VERSION}; #{RUBY_VERSION}; #{RUBY_PLATFORM}"
30
+ }.freeze
30
31
 
31
32
  class << self
32
33
  # The sender object is responsible for delivering formatted data to the
@@ -4,3 +4,4 @@ require 'honeybadger/integrations/delayed_job'
4
4
  require 'honeybadger/integrations/sidekiq'
5
5
  require 'honeybadger/integrations/thor'
6
6
  require 'honeybadger/integrations/net_http'
7
+ require 'honeybadger/integrations/passenger'
@@ -5,7 +5,11 @@ module Honeybadger
5
5
  callbacks do |lifecycle|
6
6
  lifecycle.around(:invoke_job) do |job, &block|
7
7
  begin
8
- Honeybadger::Monitor::Trace.instrument("#{job.payload_object.class}#perform", { :source => 'delayed_job', :jid => job.id, :class => job.payload_object.class.name }) do
8
+ if defined?(::Honeybadger::Monitor)
9
+ ::Honeybadger::Monitor::Trace.instrument("#{job.payload_object.class}#perform", { :source => 'delayed_job', :jid => job.id, :class => job.payload_object.class.name }) do
10
+ block.call(job)
11
+ end
12
+ else
9
13
  block.call(job)
10
14
  end
11
15
  rescue Exception => error
@@ -0,0 +1,18 @@
1
+ module Honeybadger
2
+ Dependency.register do
3
+ requirement { defined?(::PhusionPassenger) }
4
+ requirement { defined?(::Honeybadger::Monitor) }
5
+
6
+ injection do
7
+ ::PhusionPassenger.on_event(:starting_worker_process) do |forked|
8
+ Honeybadger.write_verbose_log('Starting passenger worker process')
9
+ Honeybadger::Monitor.worker.fork if forked
10
+ end
11
+
12
+ ::PhusionPassenger.on_event(:stopping_worker_process) do
13
+ Honeybadger.write_verbose_log('Stopping passenger worker process')
14
+ Honeybadger::Monitor.worker.stop
15
+ end
16
+ end
17
+ end
18
+ end
@@ -14,6 +14,7 @@ module Honeybadger
14
14
 
15
15
  Dependency.register do
16
16
  requirement { defined?(::Sidekiq) }
17
+ requirement { defined?(::Honeybadger::Monitor) }
17
18
 
18
19
  injection do
19
20
  ::Sidekiq.configure_server do |config|
@@ -21,6 +21,8 @@ module Honeybadger
21
21
  end
22
22
 
23
23
  def start
24
+ Honeybadger.write_verbose_log('Starting worker')
25
+
24
26
  @thread = MetricsThread.new do
25
27
  begin
26
28
  until Thread.current[:should_exit] do
@@ -36,9 +38,24 @@ module Honeybadger
36
38
  end
37
39
 
38
40
  def stop
41
+ Honeybadger.write_verbose_log('Stopping worker')
39
42
  @thread[:should_exit] = true if @thread
40
43
  end
41
44
 
45
+ def fork
46
+ Honeybadger.write_verbose_log('Forking worker')
47
+
48
+ stop
49
+
50
+ @lock.unlock if @lock.locked?
51
+ @lock.synchronize do
52
+ init_metrics
53
+ init_traces
54
+ end
55
+
56
+ start
57
+ end
58
+
42
59
  def timing(name, value)
43
60
  add_metric(name, value, :timing)
44
61
  end
@@ -94,6 +111,9 @@ module Honeybadger
94
111
  def send_metrics
95
112
  metrics = collect_metrics
96
113
  return unless metrics[:timing].any? || metrics[:counter].any?
114
+
115
+ Honeybadger.write_verbose_log('Sending metrics')
116
+
97
117
  [].tap do |m|
98
118
  metrics[:counter].each do |metric, values|
99
119
  m << "#{metric} #{values.sum}"
@@ -117,7 +137,12 @@ module Honeybadger
117
137
  end
118
138
 
119
139
  def send_traces
120
- collect_traces.each_slice(@per_request) do |t|
140
+ traces = collect_traces
141
+ return unless traces.any?
142
+
143
+ Honeybadger.write_verbose_log('Sending traces')
144
+
145
+ traces.each_slice(@per_request) do |t|
121
146
  begin
122
147
  @sender.send_traces({ :traces => t.compact.map(&:to_h), :environment => Honeybadger.configuration.environment_name, :hostname => Honeybadger.configuration.hostname })
123
148
  rescue Exception => e
@@ -0,0 +1,29 @@
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
+
@@ -12,6 +12,31 @@ describe Honeybadger::Monitor::Worker do
12
12
  instance.stub(:metrics) { instance.instance_variable_get(:@metrics) }
13
13
  instance.stub(:traces) { instance.instance_variable_get(:@traces) }
14
14
  instance.stub(:sender) { instance.instance_variable_get(:@sender) }
15
+ instance.stub(:thread) { instance.instance_variable_get(:@thread) }
16
+ instance.stub(:lock) { instance.instance_variable_get(:@lock) }
17
+ end
18
+
19
+ describe "#fork" do
20
+ before { Thread.unstub(:new) }
21
+ before { Honeybadger.stub(:write_verbose_log) }
22
+ before { subject.start }
23
+ after { subject.stop }
24
+
25
+ it "logs debug information" do
26
+ Honeybadger.should_receive(:write_verbose_log).with(/forking/i)
27
+ subject.fork
28
+ end
29
+
30
+ it "restarts the worker thread" do
31
+ old_thread = instance.thread
32
+ subject.fork
33
+ expect(instance.thread).not_to be old_thread
34
+ end
35
+
36
+ it "unlocks the mutex first" do
37
+ instance.lock.lock
38
+ expect { subject.fork }.not_to raise_error
39
+ end
15
40
  end
16
41
 
17
42
  describe '#initialize' do
@@ -9,6 +9,12 @@ describe Honeybadger::Sender do
9
9
  Honeybadger.notify(RuntimeError.new('oops!'))
10
10
  end
11
11
 
12
+ it "sends a user agent with version number" do
13
+ http = stub_http
14
+ http.should_receive(:post).with(kind_of(String), kind_of(String), hash_including({'User-Agent' => "HB-Ruby #{Honeybadger::VERSION}; #{RUBY_VERSION}; #{RUBY_PLATFORM}"}))
15
+ send_exception
16
+ end
17
+
12
18
  it "posts to Honeybadger when using an HTTP proxy" do
13
19
  http = stub_http
14
20
  proxy = double(:new => http)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.2
4
+ version: 1.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Wood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -261,6 +261,7 @@ files:
261
261
  - lib/honeybadger/integrations/delayed_job.rb
262
262
  - lib/honeybadger/integrations/delayed_job/plugin.rb
263
263
  - lib/honeybadger/integrations/net_http.rb
264
+ - lib/honeybadger/integrations/passenger.rb
264
265
  - lib/honeybadger/integrations/sidekiq.rb
265
266
  - lib/honeybadger/integrations/thor.rb
266
267
  - lib/honeybadger/monitor.rb
@@ -301,6 +302,7 @@ files:
301
302
  - spec/honeybadger/exception_extensions_spec.rb
302
303
  - spec/honeybadger/integrations/delayed_job_spec.rb
303
304
  - spec/honeybadger/integrations/net_http_spec.rb
305
+ - spec/honeybadger/integrations/passenger_spec.rb
304
306
  - spec/honeybadger/integrations/sidekiq_spec.rb
305
307
  - spec/honeybadger/integrations/thor_spec.rb
306
308
  - spec/honeybadger/logger_spec.rb