appsignal 0.8.15 → 0.9.0.alpha.1

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -2
  3. data/README.md +4 -0
  4. data/Rakefile +8 -0
  5. data/appsignal.gemspec +0 -1
  6. data/gemfiles/capistrano2.gemfile +5 -0
  7. data/gemfiles/capistrano3.gemfile +5 -0
  8. data/lib/appsignal.rb +10 -4
  9. data/lib/appsignal/agent.rb +5 -10
  10. data/lib/appsignal/capistrano.rb +8 -1
  11. data/lib/appsignal/config.rb +2 -1
  12. data/lib/appsignal/instrumentations/net_http.rb +15 -0
  13. data/lib/appsignal/integrations/capistrano/appsignal.cap +27 -0
  14. data/lib/appsignal/integrations/{capistrano.rb → capistrano/capistrano_2_tasks.rb} +2 -4
  15. data/lib/appsignal/integrations/capistrano/careful_logger.rb +1 -1
  16. data/lib/appsignal/integrations/delayed_job.rb +2 -4
  17. data/lib/appsignal/integrations/resque.rb +2 -4
  18. data/lib/appsignal/integrations/sidekiq.rb +2 -4
  19. data/lib/appsignal/marker.rb +1 -1
  20. data/lib/appsignal/rack/instrumentation.rb +1 -0
  21. data/lib/appsignal/rack/listener.rb +3 -4
  22. data/lib/appsignal/transaction.rb +16 -4
  23. data/lib/appsignal/version.rb +1 -1
  24. data/spec/lib/appsignal/agent_spec.rb +1 -23
  25. data/spec/lib/appsignal/config_spec.rb +2 -0
  26. data/spec/lib/appsignal/instrumentations/net_http_spec.rb +26 -0
  27. data/spec/lib/appsignal/integrations/capistrano2_spec.rb +178 -0
  28. data/spec/lib/appsignal/integrations/capistrano3_spec.rb +169 -0
  29. data/spec/lib/appsignal/integrations/resque_spec.rb +1 -1
  30. data/spec/lib/appsignal/marker_spec.rb +13 -10
  31. data/spec/lib/appsignal/transaction_spec.rb +34 -13
  32. data/spec/lib/appsignal_spec.rb +35 -0
  33. data/spec/lib/generators/appsignal/appsignal_generator_spec.rb +13 -14
  34. data/spec/spec_helper.rb +14 -0
  35. metadata +15 -21
  36. data/spec/lib/appsignal/integrations/capistrano_spec.rb +0 -151
@@ -54,6 +54,11 @@ describe Appsignal do
54
54
  Appsignal.start
55
55
  end
56
56
 
57
+ it "should load instrumentations" do
58
+ Appsignal.should_receive(:load_instrumentations)
59
+ Appsignal.start
60
+ end
61
+
57
62
  context "with an extension" do
58
63
  before { Appsignal.extensions << Appsignal::MockExtension }
59
64
 
@@ -64,6 +69,36 @@ describe Appsignal do
64
69
  end
65
70
  end
66
71
 
72
+ describe ".load_integrations" do
73
+ it "should require the integrations" do
74
+ Appsignal.should_receive(:require).at_least(:once)
75
+ end
76
+
77
+ after { Appsignal.load_integrations }
78
+ end
79
+
80
+ describe ".load_instrumentations" do
81
+ before { Appsignal.config = project_fixture_config }
82
+
83
+ context "Net::HTTP" do
84
+ context "if on in the config" do
85
+ it "should require net_http" do
86
+ Appsignal.should_receive(:require).with('appsignal/instrumentations/net_http')
87
+ end
88
+ end
89
+
90
+ context "if off in the config" do
91
+ before { Appsignal.config.config_hash[:instrument_net_http] = false }
92
+
93
+ it "should not require net_http" do
94
+ Appsignal.should_not_receive(:require).with('appsignal/instrumentations/net_http')
95
+ end
96
+ end
97
+ end
98
+
99
+ after { Appsignal.load_instrumentations }
100
+ end
101
+
67
102
  context "with debug logging" do
68
103
  before { Appsignal.config = project_fixture_config('test') }
69
104
 
@@ -20,9 +20,11 @@ if rails_present?
20
20
  include GeneratorSpec::TestCase
21
21
  destination tmp_dir
22
22
 
23
+ let(:authcheck) { Appsignal::AuthCheck.new(nil, nil) }
23
24
  let(:err_stream) { StringIO.new }
24
25
 
25
26
  before do
27
+ Appsignal::AuthCheck.stub(:new => authcheck)
26
28
  FileUtils.rm_rf(tmp_dir)
27
29
  @original_stderr = $stderr
28
30
  $stderr = err_stream
@@ -34,9 +36,7 @@ if rails_present?
34
36
  context "with key" do
35
37
  context "known key" do
36
38
  before do
37
- authcheck = double
38
- Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
39
- authcheck.should_receive(:perform_with_result).and_return(['200', 'everything ok'])
39
+ authcheck.should_receive(:perform).and_return('200')
40
40
 
41
41
  prepare_destination
42
42
  run_generator_in_tmp %w(my_app_key)
@@ -50,45 +50,42 @@ if rails_present?
50
50
  end
51
51
 
52
52
  it "should mention successful auth check" do
53
- @output.should include('success everything ok')
53
+ @output.should include('success')
54
+ @output.should include('AppSignal has confirmed authorization!')
54
55
  end
55
56
  end
56
57
 
57
58
  context "invalid key" do
58
59
  before do
59
- authcheck = double
60
- Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
61
- authcheck.should_receive(:perform_with_result).and_return(['401', 'unauthorized'])
60
+ authcheck.should_receive(:perform).and_return('401')
62
61
 
63
62
  prepare_destination
64
63
  run_generator_in_tmp %w(my_app_key)
65
64
  end
66
65
 
67
66
  it "should mention invalid key" do
68
- @output.should include('error unauthorized')
67
+ @output.should include('error')
68
+ @output.should include('API key not valid with AppSignal...')
69
69
  end
70
70
  end
71
71
 
72
72
  context "failed check" do
73
73
  before do
74
- authcheck = double
75
- Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
76
- authcheck.should_receive(:perform_with_result).and_return(['500', 'error!'])
74
+ authcheck.should_receive(:perform).and_return('500')
77
75
 
78
76
  prepare_destination
79
77
  run_generator_in_tmp %w(my_app_key)
80
78
  end
81
79
 
82
80
  it "should mention failed check" do
83
- @output.should include('error error!')
81
+ @output.should include('error')
82
+ @output.should include('Could not confirm authorization')
84
83
  end
85
84
  end
86
85
 
87
86
  context "internal failure" do
88
87
  before do
89
- authcheck = Appsignal::AuthCheck.new(nil, nil)
90
88
  authcheck.stub(:perform).and_throw(:error)
91
- Appsignal::AuthCheck.should_receive(:new).and_return(authcheck)
92
89
 
93
90
  prepare_destination
94
91
  run_generator_in_tmp %w(my_app_key)
@@ -123,6 +120,7 @@ if rails_present?
123
120
  context "without capistrano" do
124
121
  before do
125
122
  prepare_destination
123
+ authcheck.stub(:perform).and_return(['200', 'everything ok'])
126
124
  run_generator_in_tmp %w(my_app_key)
127
125
  end
128
126
 
@@ -150,6 +148,7 @@ if rails_present?
150
148
  File.open(cap_file, 'w') {}
151
149
  FileUtils.mkdir(File.join(destination_root, 'config'))
152
150
  File.open(deploy_file, 'w') {}
151
+ authcheck.stub(:perform).and_return(['200', 'everything ok'])
153
152
  run_generator_in_tmp %w(my_app_key)
154
153
  end
155
154
 
data/spec/spec_helper.rb CHANGED
@@ -18,6 +18,20 @@ def rails_present?
18
18
  RAILS_PRESENT
19
19
  end
20
20
 
21
+ def capistrano_present?
22
+ !! Gem.loaded_specs['capistrano']
23
+ end
24
+
25
+ def capistrano2_present?
26
+ capistrano_present? &&
27
+ Gem.loaded_specs['capistrano'].version < Gem::Version.new('3.0')
28
+ end
29
+
30
+ def capistrano3_present?
31
+ capistrano_present? &&
32
+ Gem.loaded_specs['capistrano'].version >= Gem::Version.new('3.0')
33
+ end
34
+
21
35
  require 'appsignal'
22
36
 
23
37
  Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support/helpers','*.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.8.15
4
+ version: 0.9.0.alpha.1
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-06-24 00:00:00.000000000 Z
15
+ date: 2014-06-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -84,20 +84,6 @@ dependencies:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
- - !ruby/object:Gem::Dependency
88
- name: capistrano
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - "<"
92
- - !ruby/object:Gem::Version
93
- version: '3.0'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - "<"
99
- - !ruby/object:Gem::Version
100
- version: '3.0'
101
87
  - !ruby/object:Gem::Dependency
102
88
  name: pry
103
89
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +129,8 @@ files:
143
129
  - Rakefile
144
130
  - appsignal.gemspec
145
131
  - bin/appsignal
132
+ - gemfiles/capistrano2.gemfile
133
+ - gemfiles/capistrano3.gemfile
146
134
  - gemfiles/no_dependencies.gemfile
147
135
  - gemfiles/rails-3.0.gemfile
148
136
  - gemfiles/rails-3.1.gemfile
@@ -163,7 +151,9 @@ files:
163
151
  - lib/appsignal/capistrano.rb
164
152
  - lib/appsignal/cli.rb
165
153
  - lib/appsignal/config.rb
166
- - lib/appsignal/integrations/capistrano.rb
154
+ - lib/appsignal/instrumentations/net_http.rb
155
+ - lib/appsignal/integrations/capistrano/appsignal.cap
156
+ - lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
167
157
  - lib/appsignal/integrations/capistrano/careful_logger.rb
168
158
  - lib/appsignal/integrations/delayed_job.rb
169
159
  - lib/appsignal/integrations/passenger.rb
@@ -195,7 +185,9 @@ files:
195
185
  - spec/lib/appsignal/auth_check_spec.rb
196
186
  - spec/lib/appsignal/cli_spec.rb
197
187
  - spec/lib/appsignal/config_spec.rb
198
- - spec/lib/appsignal/integrations/capistrano_spec.rb
188
+ - spec/lib/appsignal/instrumentations/net_http_spec.rb
189
+ - spec/lib/appsignal/integrations/capistrano2_spec.rb
190
+ - spec/lib/appsignal/integrations/capistrano3_spec.rb
199
191
  - spec/lib/appsignal/integrations/delayed_job_spec.rb
200
192
  - spec/lib/appsignal/integrations/passenger_spec.rb
201
193
  - spec/lib/appsignal/integrations/rails_spec.rb
@@ -240,9 +232,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
232
  version: 1.9.3
241
233
  required_rubygems_version: !ruby/object:Gem::Requirement
242
234
  requirements:
243
- - - ">="
235
+ - - ">"
244
236
  - !ruby/object:Gem::Version
245
- version: '0'
237
+ version: 1.3.1
246
238
  requirements: []
247
239
  rubyforge_project:
248
240
  rubygems_version: 2.2.2
@@ -260,7 +252,9 @@ test_files:
260
252
  - spec/lib/appsignal/auth_check_spec.rb
261
253
  - spec/lib/appsignal/cli_spec.rb
262
254
  - spec/lib/appsignal/config_spec.rb
263
- - spec/lib/appsignal/integrations/capistrano_spec.rb
255
+ - spec/lib/appsignal/instrumentations/net_http_spec.rb
256
+ - spec/lib/appsignal/integrations/capistrano2_spec.rb
257
+ - spec/lib/appsignal/integrations/capistrano3_spec.rb
264
258
  - spec/lib/appsignal/integrations/delayed_job_spec.rb
265
259
  - spec/lib/appsignal/integrations/passenger_spec.rb
266
260
  - spec/lib/appsignal/integrations/rails_spec.rb
@@ -1,151 +0,0 @@
1
- require 'spec_helper'
2
- require 'appsignal/capistrano'
3
- require 'capistrano/configuration'
4
-
5
- describe Appsignal::Integrations::Capistrano do
6
- let(:config) { project_fixture_config }
7
-
8
- before :all do
9
- @capistrano_config = Capistrano::Configuration.new
10
- Appsignal::Integrations::Capistrano.tasks(@capistrano_config)
11
- end
12
-
13
- it "should have a deploy task" do
14
- @capistrano_config.find_task('appsignal:deploy').should_not be_nil
15
- end
16
-
17
- describe "appsignal:deploy task" do
18
- before do
19
- @capistrano_config.set(:rails_env, 'production')
20
- @capistrano_config.set(:repository, 'master')
21
- @capistrano_config.set(:deploy_to, '/home/username/app')
22
- @capistrano_config.set(:current_release, '')
23
- @capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
24
- @capistrano_config.dry_run = false
25
- ENV['USER'] = 'batman'
26
- ENV['PWD'] = project_fixture_path
27
- end
28
-
29
- context "config" do
30
- before do
31
- @capistrano_config.dry_run = true
32
- end
33
-
34
- it "should be instantiated with the right params" do
35
- Appsignal::Config.should_receive(:new).with(
36
- project_fixture_path,
37
- 'production',
38
- {},
39
- kind_of(Capistrano::Logger)
40
- )
41
- end
42
-
43
- context "when appsignal_config is available" do
44
- before do
45
- @capistrano_config.set(:appsignal_config, :name => 'AppName')
46
- end
47
-
48
- it "should be instantiated with the right params" do
49
- Appsignal::Config.should_receive(:new).with(
50
- project_fixture_path,
51
- 'production',
52
- {:name => 'AppName'},
53
- kind_of(Capistrano::Logger)
54
- )
55
- end
56
-
57
- context "when rack_env is used instead of rails_env" do
58
- before do
59
- @capistrano_config.unset(:rails_env)
60
- @capistrano_config.set(:rack_env, 'rack_production')
61
- end
62
-
63
- it "should be instantiated with the right params" do
64
- Appsignal::Config.should_receive(:new).with(
65
- project_fixture_path,
66
- 'rack_production',
67
- {:name => 'AppName'},
68
- kind_of(Capistrano::Logger)
69
- )
70
- end
71
- end
72
- end
73
-
74
- after { @capistrano_config.find_and_execute_task('appsignal:deploy') }
75
- end
76
-
77
- context "send marker" do
78
- before :all do
79
- @io = StringIO.new
80
- @logger = Capistrano::Logger.new(:output => @io)
81
- @logger.level = Capistrano::Logger::MAX_LEVEL
82
- @capistrano_config.logger = @logger
83
- end
84
-
85
- let(:marker_data) do
86
- {
87
- :revision => '503ce0923ed177a3ce000005',
88
- :repository => 'master',
89
- :user => 'batman'
90
- }
91
- end
92
-
93
- context "when active for this environment" do
94
- before do
95
- @marker = Appsignal::Marker.new(
96
- marker_data,
97
- config,
98
- @logger
99
- )
100
- Appsignal::Marker.should_receive(:new).with(
101
- marker_data,
102
- kind_of(Appsignal::Config),
103
- kind_of(Capistrano::Logger)
104
- ).and_return(@marker)
105
- end
106
-
107
- context "proper setup" do
108
- before do
109
- @transmitter = double
110
- Appsignal::Transmitter.should_receive(:new).and_return(@transmitter)
111
- end
112
-
113
- it "should transmit data" do
114
- @transmitter.should_receive(:transmit).and_return('200')
115
- @capistrano_config.find_and_execute_task('appsignal:deploy')
116
- @io.string.should include('** Notifying Appsignal of deploy...')
117
- @io.string.should include('** Appsignal has been notified of this deploy!')
118
- end
119
- end
120
-
121
- it "should not transmit data" do
122
- @capistrano_config.find_and_execute_task('appsignal:deploy')
123
- @io.string.should include('** Notifying Appsignal of deploy...')
124
- @io.string.should include('** Something went wrong while trying to notify Appsignal:')
125
- end
126
-
127
- context "dry run" do
128
- before { @capistrano_config.dry_run = true }
129
-
130
- it "should not send deploy marker" do
131
- @marker.should_not_receive(:transmit)
132
- @capistrano_config.find_and_execute_task('appsignal:deploy')
133
- @io.string.should include('** Dry run: Deploy marker not actually sent.')
134
- end
135
- end
136
- end
137
-
138
- context "when not active for this environment" do
139
- before do
140
- @capistrano_config.set(:rails_env, 'nonsense')
141
- end
142
-
143
- it "should not send deploy marker" do
144
- Appsignal::Marker.should_not_receive(:new)
145
- @capistrano_config.find_and_execute_task('appsignal:deploy')
146
- @io.string.should include('Not loading:')
147
- end
148
- end
149
- end
150
- end
151
- end