appsignal 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.md +4 -0
- data/README.md +4 -2
- data/Rakefile +59 -33
- data/appsignal.gemspec +2 -1
- data/lib/appsignal.rb +2 -2
- data/lib/appsignal/agent.rb +6 -6
- data/lib/appsignal/instrumentations/net_http.rb +1 -1
- data/lib/appsignal/integrations/passenger.rb +1 -1
- data/lib/appsignal/integrations/unicorn.rb +1 -1
- data/lib/appsignal/pipe.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/agent_spec.rb +7 -2
- data/spec/lib/appsignal/instrumentations/net_http_spec.rb +3 -5
- data/spec/lib/appsignal/integrations/unicorn_spec.rb +1 -1
- data/spec/lib/appsignal/transmitter_spec.rb +15 -4
- data/spec/spec_helper.rb +3 -0
- data/spec/support/helpers/transaction_helpers.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6fabcd77c8c0eb7a8615638ddbb88828898d3b
|
4
|
+
data.tar.gz: 9b03941f52cdcf2d53e813e012db9df9f17ffe69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f364fdba3b42c9584bf44def9a4c26c93494c94812f42fc0447a04822141d47fc16b27338638b38413348c5118025301b5129a9d167e1837f13cfdf8b5d0d8
|
7
|
+
data.tar.gz: e0d68e78188d52ef841d1adbf24f4d485dede6d2435f2728686e9e246fb03d4c4b1e3a192f077e434ad127f6cfff55a6b1a6c1418c0fdd44fa326a41c8afb937
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -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:
|
data/CHANGELOG.md
CHANGED
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=
|
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
|
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
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
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
|
data/appsignal.gemspec
CHANGED
@@ -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'
|
data/lib/appsignal.rb
CHANGED
@@ -40,14 +40,14 @@ module Appsignal
|
|
40
40
|
else
|
41
41
|
logger.level = Logger::INFO
|
42
42
|
end
|
43
|
-
logger.info("Starting
|
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")
|
data/lib/appsignal/agent.rb
CHANGED
@@ -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(
|
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
|
data/lib/appsignal/pipe.rb
CHANGED
data/lib/appsignal/version.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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 == '
|
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
|
-
|
23
|
-
|
24
|
-
|
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(:
|
37
|
+
subject { instance.transmit(:the => :payload) }
|
27
38
|
|
28
39
|
it { should == '200' }
|
29
40
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -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}
|
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.
|
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-
|
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:
|
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:
|
116
|
+
name: webmock
|
103
117
|
requirement: !ruby/object:Gem::Requirement
|
104
118
|
requirements:
|
105
119
|
- - ">="
|