appsignal 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7eedd9936232477c100eac06f2aea6dc5bccb2a
4
- data.tar.gz: 0b4b73db37c765d0ef960fbc122bedf0245262a4
3
+ metadata.gz: 7c6fabcd77c8c0eb7a8615638ddbb88828898d3b
4
+ data.tar.gz: 9b03941f52cdcf2d53e813e012db9df9f17ffe69
5
5
  SHA512:
6
- metadata.gz: 1677adffc11b7a580c2cdee998fdda156b3165b7acb2cb947eaebb11361608ed57fd839e8dfd71d0d730c5449b1dfa00588444b92dd5503069bd070e88c563d1
7
- data.tar.gz: f109c182a19213d097a301bb1ef8d7861421842702c83ece69825c5e6a71f9ec32a39619160a470730e681acdb7a991baff0a41dcef67aff5c81c13194bb6fcf
6
+ metadata.gz: 77f364fdba3b42c9584bf44def9a4c26c93494c94812f42fc0447a04822141d47fc16b27338638b38413348c5118025301b5129a9d167e1837f13cfdf8b5d0d8
7
+ data.tar.gz: e0d68e78188d52ef841d1adbf24f4d485dede6d2435f2728686e9e246fb03d4c4b1e3a192f077e434ad127f6cfff55a6b1a6c1418c0fdd44fa326a41c8afb937
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ Gemfile.lock
20
20
  gemfiles/*.lock
21
21
  .DS_Store
22
22
  .ruby-version
23
+ bundle_and_spec_all_rbenv.sh
24
+ bundle_and_spec_all_rvm.sh
@@ -8,6 +8,8 @@ rvm:
8
8
  - "rbx"
9
9
 
10
10
  gemfile:
11
+ - "gemfiles/capistrano2.gemfile"
12
+ - "gemfiles/capistrano3.gemfile"
11
13
  - "gemfiles/no_dependencies.gemfile"
12
14
  - "gemfiles/rails-3.0.gemfile"
13
15
  - "gemfiles/rails-3.1.gemfile"
@@ -18,7 +20,6 @@ gemfile:
18
20
 
19
21
  matrix:
20
22
  allow_failures:
21
- - rvm: "jruby-19mode"
22
23
  - rvm: "rbx"
23
24
 
24
25
  env:
@@ -1,3 +1,7 @@
1
+ # 0.9.2
2
+ * Log Ruby version and platform on startup
3
+ * Log reason of shutting down agent
4
+
1
5
  # 0.9.1
2
6
  * Some debug logging tweaks
3
7
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ AppSignal agent
4
4
  This gem collects error and performance data from your Rails
5
5
  applications and sends it to [AppSignal](https://appsignal.com)
6
6
 
7
- [![Build Status](https://travis-ci.org/appsignal/appsignal.png?branch=develop)](https://travis-ci.org/appsignal/appsignal)
7
+ [![Build Status](https://travis-ci.org/appsignal/appsignal.png?branch=master)](https://travis-ci.org/appsignal/appsignal)
8
8
  [![Gem Version](https://badge.fury.io/rb/appsignal.svg)](http://badge.fury.io/rb/appsignal)
9
9
  [![Code Climate](https://codeclimate.com/github/appsignal/appsignal.png)](https://codeclimate.com/github/appsignal/appsignal)
10
10
 
@@ -84,4 +84,6 @@ BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec
84
84
  BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec
85
85
  ```
86
86
 
87
- Or run `rake spec` to run specs for all Gemfiles. Travis will run specs for these Gemfiles as well.
87
+ Or run `rake generate_bundle_and_spec_all` to generate a script that runs specs for all
88
+ Ruby versions and gem combinations we support.
89
+ You need Rvm or Rbenv to do this. Travis will run specs for these combinations as well.
data/Rakefile CHANGED
@@ -1,3 +1,28 @@
1
+ GEMFILES = %w(
2
+ capistrano2
3
+ capistrano3
4
+ no_dependencies
5
+ rails-3.0
6
+ rails-3.1
7
+ rails-3.2
8
+ rails-4.0
9
+ rails-4.1
10
+ sinatra
11
+ )
12
+
13
+ RUBY_VERSIONS = %w(
14
+ 1.9.3-p429
15
+ 2.0.0-p451
16
+ 2.1.2
17
+ jruby-1.7.9
18
+ rbx-2.2.9
19
+ )
20
+
21
+ VERSION_MANAGERS = {
22
+ :rbenv => 'rbenv local',
23
+ :rvm => 'rvm use'
24
+ }
25
+
1
26
  task :publish do
2
27
  require 'appsignal/version'
3
28
 
@@ -59,44 +84,45 @@ task :publish do
59
84
  end
60
85
 
61
86
  task :bundle do
62
- system 'bundle --gemfile gemfiles/capistrano2.gemfile'
63
- system 'bundle --gemfile gemfiles/capistrano3.gemfile'
64
- system 'bundle --gemfile gemfiles/no_dependencies.gemfile'
65
- system 'bundle --gemfile gemfiles/rails-3.0.gemfile'
66
- system 'bundle --gemfile gemfiles/rails-3.1.gemfile'
67
- system 'bundle --gemfile gemfiles/rails-3.2.gemfile'
68
- system 'bundle --gemfile gemfiles/rails-4.0.gemfile'
69
- system 'bundle --gemfile gemfiles/rails-4.1.gemfile'
70
- system 'bundle --gemfile gemfiles/sinatra.gemfile'
87
+ GEMFILES.each do |gemfile|
88
+ system "bundle --gemfile gemfiles/#{gemfile}.gemfile"
89
+ end
71
90
  end
72
91
 
73
92
  task :spec do
74
- puts 'Running capistrano2'
75
- system 'env BUNDLE_GEMFILE=gemfiles/capistrano2.gemfile bundle exec rspec'
76
-
77
- puts 'Running capistrano3'
78
- system 'env BUNDLE_GEMFILE=gemfiles/capistrano3.gemfile bundle exec rspec'
79
-
80
- puts 'Running no dependencies'
81
- system 'env BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec'
82
-
83
- puts 'Running rails-3.0'
84
- system 'env BUNDLE_GEMFILE=gemfiles/rails-3.0.gemfile bundle exec rspec'
85
-
86
- puts 'Running rails-3.1'
87
- system 'env BUNDLE_GEMFILE=gemfiles/rails-3.1.gemfile bundle exec rspec'
88
-
89
- puts 'Running rails-3.2'
90
- system 'env BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec'
91
-
92
- puts 'Running rails-4.0'
93
- system 'env BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec'
93
+ GEMFILES.each do |gemfile|
94
+ puts "Running #{gemfile}"
95
+ raise 'Not successful' unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec")
96
+ end
97
+ end
94
98
 
95
- puts 'Running rails-4.1'
96
- system 'env BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec'
99
+ task :generate_bundle_and_spec_all do
100
+ VERSION_MANAGERS.each do |version_manager, switch_command|
101
+ out = []
102
+ out << '#!/bin/sh'
103
+ out << 'rm -f .ruby-version'
104
+
105
+ out << "echo 'Using #{version_manager}'"
106
+ RUBY_VERSIONS.each do |version|
107
+ out << "echo 'Switching to #{version}'"
108
+ out << "#{switch_command} #{version} || { echo 'Switching Ruby failed'; exit 1; }"
109
+ GEMFILES.each do |gemfile|
110
+ out << "echo 'Bundling #{gemfile} in #{version}'"
111
+ out << "bundle --quiet --gemfile gemfiles/#{gemfile}.gemfile || { echo 'Bundling failed'; exit 1; }"
112
+ out << "echo 'Running #{gemfile} in #{version}'"
113
+ out << "env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec || { echo 'Running specs failed'; exit 1; }"
114
+ end
115
+ end
116
+ out << 'rm .ruby-version'
117
+ out << "echo 'Successfully ran specs for all environments'"
97
118
 
98
- puts 'Running sinatra'
99
- system 'env BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec'
119
+ script = "bundle_and_spec_all_#{version_manager}.sh"
120
+ File.open(script, 'w') do |file|
121
+ file.write out.join("\n")
122
+ end
123
+ File.chmod(0775, script)
124
+ puts "Generated #{script}"
125
+ end
100
126
  end
101
127
 
102
128
  task :console do
@@ -29,9 +29,10 @@ Gem::Specification.new do |gem|
29
29
  gem.add_dependency 'thread_safe'
30
30
 
31
31
  gem.add_development_dependency 'rake'
32
- gem.add_development_dependency 'rspec'
32
+ gem.add_development_dependency 'rspec', '~> 2.14.1'
33
33
  gem.add_development_dependency 'pry'
34
34
  gem.add_development_dependency 'timecop'
35
+ gem.add_development_dependency 'webmock'
35
36
 
36
37
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
37
38
  gem.add_development_dependency 'racc'
@@ -40,14 +40,14 @@ module Appsignal
40
40
  else
41
41
  logger.level = Logger::INFO
42
42
  end
43
- logger.info("Starting appsignal-#{Appsignal::VERSION}")
43
+ logger.info("Starting AppSignal #{Appsignal::VERSION} on #{RUBY_VERSION}/#{RUBY_PLATFORM}")
44
44
  load_integrations
45
45
  load_instrumentations
46
46
  initialize_extensions
47
47
  @agent = Appsignal::Agent.new
48
48
  at_exit do
49
49
  logger.debug('Running at_exit block')
50
- @agent.shutdown(true)
50
+ @agent.shutdown(true, 'ran at_exit')
51
51
  end
52
52
  else
53
53
  logger.error("Can't start, no config loaded")
@@ -110,8 +110,8 @@ module Appsignal
110
110
  restart_thread
111
111
  end
112
112
 
113
- def shutdown(send_current_queue=false)
114
- Appsignal.logger.info('Shutting down agent')
113
+ def shutdown(send_current_queue=false, reason=nil)
114
+ Appsignal.logger.info("Shutting down agent (#{reason})")
115
115
  ActiveSupport::Notifications.unsubscribe(subscriber)
116
116
  Thread.kill(thread) if thread
117
117
  send_queue if send_current_queue && @aggregator.has_transactions?
@@ -131,16 +131,16 @@ module Appsignal
131
131
  @sleep_time = sleep_time / 1.5
132
132
  when 429
133
133
  Appsignal.logger.error 'Too many requests sent'
134
- shutdown
134
+ shutdown(false, 429)
135
135
  when 406
136
136
  Appsignal.logger.error 'Your appsignal gem cannot communicate with the API anymore, please upgrade.'
137
- shutdown
137
+ shutdown(false, 406)
138
138
  when 402
139
139
  Appsignal.logger.error 'Payment required'
140
- shutdown
140
+ shutdown(false, 402)
141
141
  when 401
142
142
  Appsignal.logger.error 'API token cannot be authorized'
143
- shutdown
143
+ shutdown(false, 401)
144
144
  else
145
145
  Appsignal.logger.error "Unknown Appsignal response code: '#{code}'"
146
146
  clear_queue
@@ -4,7 +4,7 @@ Net::HTTP.class_eval do
4
4
  def request(request, body=nil, &block)
5
5
  ActiveSupport::Notifications.instrument(
6
6
  'request.net_http',
7
- :host => request['host'],
7
+ :host => request['host'] || self.address,
8
8
  :scheme => use_ssl? ? 'https' : 'http',
9
9
  :path => request.path,
10
10
  :method => request.method
@@ -8,6 +8,6 @@ if defined?(::PhusionPassenger)
8
8
 
9
9
  ::PhusionPassenger.on_event(:stopping_worker_process) do
10
10
  Appsignal.logger.debug('stopping worker process')
11
- Appsignal.agent.shutdown(true)
11
+ Appsignal.agent.shutdown(true, 'stopping Passenger worker process')
12
12
  end
13
13
  end
@@ -18,7 +18,7 @@ if defined?(::Unicorn)
18
18
  alias_method :original_close, :close
19
19
 
20
20
  def close
21
- Appsignal.agent.shutdown(true)
21
+ Appsignal.agent.shutdown(true, 'stopping Unicorn worker process')
22
22
  original_close
23
23
  end
24
24
  end
@@ -17,7 +17,7 @@ module Appsignal
17
17
  Marshal::dump(transaction, @writer)
18
18
  rescue IOError
19
19
  Appsignal.logger.debug "Broken pipe in #{$$}"
20
- Appsignal.agent.shutdown
20
+ Appsignal.agent.shutdown(true, 'broken pipe')
21
21
  end
22
22
 
23
23
  def stop_listening!
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.9.1'
2
+ VERSION = '0.9.2'
3
3
  end
@@ -292,6 +292,11 @@ describe Appsignal::Agent do
292
292
  end
293
293
 
294
294
  context "when not sending the current queue" do
295
+ it "should log the reason for shutting down" do
296
+ Appsignal.logger.should_receive(:info).with('Shutting down agent (shutting down)')
297
+ subject.shutdown(false, 'shutting down')
298
+ end
299
+
295
300
  context "with an empty queue" do
296
301
  it "should shutdown" do
297
302
  subject.shutdown
@@ -313,7 +318,7 @@ describe Appsignal::Agent do
313
318
  it "should shutdown" do
314
319
  subject.should_not_receive(:send_queue)
315
320
 
316
- subject.shutdown(true)
321
+ subject.shutdown(true, nil)
317
322
  end
318
323
  end
319
324
 
@@ -322,7 +327,7 @@ describe Appsignal::Agent do
322
327
  subject.enqueue(slow_transaction)
323
328
  subject.should_receive(:send_queue)
324
329
 
325
- subject.shutdown(true)
330
+ subject.shutdown(true, nil)
326
331
  end
327
332
  end
328
333
  end
@@ -10,16 +10,14 @@ describe "Net::HTTP instrumentation" do
10
10
  end
11
11
 
12
12
  it "should instrument request" do
13
- # We want to be absolutely sure the original method gets called correctly,
14
- # so we actually do a HTTP request.
15
- response = Net::HTTP.get_response(URI.parse('https://www.google.com'))
13
+ stub_request(:any, 'www.google.com')
16
14
 
17
- response.body.should include('google')
15
+ Net::HTTP.get_response(URI.parse('http://www.google.com'))
18
16
 
19
17
  event = events.last
20
18
  event.name.should == 'request.net_http'
21
19
  event.payload[:host].should == 'www.google.com'
22
- event.payload[:scheme].should == 'https'
20
+ event.payload[:scheme].should == 'http'
23
21
  event.payload[:path].should == '/'
24
22
  event.payload[:method].should == 'GET'
25
23
  end
@@ -33,7 +33,7 @@ describe "Unicorn integration" do
33
33
  it "should add behavior to Unicorn::Worker#close" do
34
34
  worker = Unicorn::Worker.new
35
35
 
36
- Appsignal.agent.should_receive(:shutdown).with(true)
36
+ Appsignal.agent.should_receive(:shutdown).with(true, 'stopping Unicorn worker process')
37
37
  worker.should_receive(:original_close)
38
38
 
39
39
  worker.close
@@ -19,11 +19,22 @@ describe Appsignal::Transmitter do
19
19
  end
20
20
 
21
21
  describe "#transmit" do
22
- let(:response) { double(:response, :code => '200') }
23
- let(:http_client) { double(:request, :request => response) }
24
- before { instance.stub(:http_client => http_client) }
22
+ before do
23
+ stub_request(
24
+ :post,
25
+ "https://push.appsignal.com/1/action?api_key=abc&environment=production&gem_version=#{Appsignal::VERSION}&hostname=#{Socket.gethostname}&name=TestApp"
26
+ ).with(
27
+ :body => Zlib::Deflate.deflate("{\"the\":\"payload\"}", Zlib::BEST_SPEED),
28
+ :headers => {
29
+ 'Content-Encoding' => 'gzip',
30
+ 'Content-Type' => 'application/json; charset=UTF-8',
31
+ }
32
+ ).to_return(
33
+ :status => 200
34
+ )
35
+ end
25
36
 
26
- subject { instance.transmit(:shipit => :payload) }
37
+ subject { instance.transmit(:the => :payload) }
27
38
 
28
39
  it { should == '200' }
29
40
  end
@@ -2,8 +2,11 @@ ENV['RAILS_ENV'] ||= 'test'
2
2
  require 'rspec'
3
3
  require 'pry'
4
4
  require 'timecop'
5
+ require 'webmock/rspec'
5
6
  require 'active_support/notifications'
6
7
 
8
+ puts "Runnings specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}"
9
+
7
10
  begin
8
11
  require 'rails'
9
12
  Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support/rails','*.rb'))].each {|f| require f}
@@ -1,6 +1,6 @@
1
1
  module TransactionHelpers
2
2
  def fixed_time
3
- @fixed_time ||= Time.new(2014, 01, 15, 12, 0).to_f
3
+ @fixed_time ||= Time.utc(2014, 01, 15, 11, 0, 0).to_f
4
4
  end
5
5
 
6
6
  def uploaded_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-07-03 00:00:00.000000000 Z
15
+ date: 2014-07-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -72,6 +72,20 @@ dependencies:
72
72
  version: '0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: 2.14.1
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: 2.14.1
87
+ - !ruby/object:Gem::Dependency
88
+ name: pry
75
89
  requirement: !ruby/object:Gem::Requirement
76
90
  requirements:
77
91
  - - ">="
@@ -85,7 +99,7 @@ dependencies:
85
99
  - !ruby/object:Gem::Version
86
100
  version: '0'
87
101
  - !ruby/object:Gem::Dependency
88
- name: pry
102
+ name: timecop
89
103
  requirement: !ruby/object:Gem::Requirement
90
104
  requirements:
91
105
  - - ">="
@@ -99,7 +113,7 @@ dependencies:
99
113
  - !ruby/object:Gem::Version
100
114
  version: '0'
101
115
  - !ruby/object:Gem::Dependency
102
- name: timecop
116
+ name: webmock
103
117
  requirement: !ruby/object:Gem::Requirement
104
118
  requirements:
105
119
  - - ">="