appsignal 0.12.rc.14 → 1.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -7
- data/CHANGELOG.md +3 -1
- data/Rakefile +36 -15
- data/ext/agent.yml +7 -7
- data/ext/appsignal_extension.c +3 -1
- data/gemfiles/rails-4.2.gemfile +1 -1
- data/gemfiles/rails-5.0.gemfile +7 -0
- data/gemfiles/resque.gemfile +5 -0
- data/lib/appsignal.rb +6 -1
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
- data/lib/appsignal/hooks.rb +0 -1
- data/lib/appsignal/hooks/rake.rb +4 -12
- data/lib/appsignal/integrations/resque.rb +15 -0
- data/lib/appsignal/subscriber.rb +2 -2
- data/lib/appsignal/transaction.rb +18 -7
- data/lib/appsignal/update_active_support.rb +20 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +7 -1
- data/spec/lib/appsignal/hooks/rake_spec.rb +8 -30
- data/spec/lib/appsignal/hooks/redis_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/resque_spec.rb +81 -0
- data/spec/lib/appsignal/transaction_spec.rb +52 -18
- data/spec/lib/appsignal/update_active_support_spec.rb +17 -0
- data/spec/spec_helper.rb +7 -0
- metadata +11 -6
- data/lib/appsignal/hooks/resque.rb +0 -28
- data/spec/lib/appsignal/hooks/resque_spec.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfb150bcd1300dfd0f72554fcfb79432a20d1c37
|
4
|
+
data.tar.gz: a4a4b0c5dea4885c6aabc140a4e31bf7090bda07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01f13f11bd5f14d9db6a35440cbf981acadef9861feb31d99f9a775ac3d39e6490eb8fd6c8cf2bf4119326205e91f9d6c3fbf14f7fc4edc4f705c2d3daf34506
|
7
|
+
data.tar.gz: a70a256d58b07fcd17ff8943ce8c182bc1f00c1d767f2b7819b7ea0accdf57b0db02a1592087db5ec2e5454ea55329d7d8cfc2ca385b5da6dc8657b40c181ec5
|
data/.travis.yml
CHANGED
@@ -1,30 +1,43 @@
|
|
1
|
+
sudo: false
|
2
|
+
|
1
3
|
language: ruby
|
2
4
|
|
3
5
|
rvm:
|
4
|
-
- "1.9.2"
|
5
6
|
- "1.9.3"
|
6
7
|
- "2.0.0"
|
7
|
-
- "2.1.
|
8
|
+
- "2.1.8"
|
9
|
+
- "2.2.4"
|
10
|
+
- "2.3.0"
|
8
11
|
- "jruby-19mode"
|
9
|
-
- "rbx"
|
10
12
|
|
11
13
|
gemfile:
|
12
14
|
- "gemfiles/capistrano2.gemfile"
|
13
15
|
- "gemfiles/capistrano3.gemfile"
|
14
16
|
- "gemfiles/no_dependencies.gemfile"
|
15
|
-
- "gemfiles/
|
16
|
-
- "gemfiles/rails-3.1.gemfile"
|
17
|
+
- "gemfiles/padrino.gemfile"
|
17
18
|
- "gemfiles/rails-3.2.gemfile"
|
18
19
|
- "gemfiles/rails-4.0.gemfile"
|
19
20
|
- "gemfiles/rails-4.1.gemfile"
|
21
|
+
- "gemfiles/rails-4.2.gemfile"
|
22
|
+
- "gemfiles/rails-5.0.gemfile"
|
23
|
+
- "gemfiles/resque.gemfile"
|
20
24
|
- "gemfiles/sequel.gemfile"
|
21
25
|
- "gemfiles/sinatra.gemfile"
|
22
26
|
|
23
27
|
matrix:
|
28
|
+
exclude:
|
29
|
+
- rvm: "1.9.3"
|
30
|
+
gemfile: "gemfiles/rails-5.0.gemfile"
|
31
|
+
- rvm: "2.0.0"
|
32
|
+
gemfile: "gemfiles/rails-5.0.gemfile"
|
33
|
+
- rvm: "2.1.8"
|
34
|
+
gemfile: "gemfiles/rails-5.0.gemfile"
|
35
|
+
- rvm: "jruby-19mode"
|
36
|
+
gemfile: "gemfiles/rails-5.0.gemfile"
|
24
37
|
allow_failures:
|
25
|
-
- rvm: "
|
38
|
+
- rvm: "jruby-19mode"
|
26
39
|
|
27
40
|
env:
|
28
41
|
global: "RAILS_ENV=test"
|
29
42
|
|
30
|
-
script: "bundle exec
|
43
|
+
script: "bundle exec rake travis"
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
# 0.
|
1
|
+
# 1.0.0
|
2
2
|
* New version of event formatting and collection
|
3
3
|
* Use native library and agent
|
4
4
|
* Use API V2
|
5
5
|
* Support for Mongoid 5
|
6
|
+
* Integration into other gems with a hooks system
|
7
|
+
* Lots of minor bug fixes and improvements
|
6
8
|
|
7
9
|
# 0.11.15
|
8
10
|
* Improve Sinatra support
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
1
3
|
GEMFILES = %w(
|
2
4
|
capistrano2
|
3
5
|
capistrano3
|
@@ -7,17 +9,24 @@ GEMFILES = %w(
|
|
7
9
|
rails-4.0
|
8
10
|
rails-4.1
|
9
11
|
rails-4.2
|
12
|
+
rails-5.0
|
13
|
+
resque
|
10
14
|
sequel
|
11
15
|
sinatra
|
12
16
|
)
|
13
17
|
|
14
18
|
RUBY_VERSIONS = %w(
|
15
|
-
1.9.3-
|
16
|
-
2.0.0-
|
17
|
-
2.1.
|
18
|
-
2.2.
|
19
|
+
1.9.3-p551
|
20
|
+
2.0.0-p648
|
21
|
+
2.1.8
|
22
|
+
2.2.4
|
23
|
+
2.3.0
|
19
24
|
)
|
20
25
|
|
26
|
+
EXCLUSIONS = {
|
27
|
+
'rails-5.0' => %w( 1.9.3-p551 2.0.0-p648 2.1.8)
|
28
|
+
}
|
29
|
+
|
21
30
|
VERSION_MANAGERS = {
|
22
31
|
:rbenv => 'rbenv local',
|
23
32
|
:rvm => 'rvm use'
|
@@ -44,10 +53,10 @@ task :publish do
|
|
44
53
|
puts `git commit -am 'Bump to #{version} [ci skip]'`
|
45
54
|
puts "# Creating tag #{version}"
|
46
55
|
puts `git tag #{version}`
|
47
|
-
puts `git push
|
48
|
-
puts `git push
|
49
|
-
puts `git push
|
50
|
-
puts `git push
|
56
|
+
puts `git push public #{version}`
|
57
|
+
puts `git push private #{version}`
|
58
|
+
puts `git push public #{branch}`
|
59
|
+
puts `git push private #{branch}`
|
51
60
|
rescue
|
52
61
|
raise "Tag: '#{version}' already exists"
|
53
62
|
end
|
@@ -100,7 +109,7 @@ task :install do
|
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
103
|
-
task :
|
112
|
+
task :spec_all_gemfiles do
|
104
113
|
GEMFILES.each do |gemfile|
|
105
114
|
puts "Running #{gemfile}"
|
106
115
|
raise 'Not successful' unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec")
|
@@ -122,13 +131,15 @@ task :generate_bundle_and_spec_all do
|
|
122
131
|
out << "#{switch_command} #{version} || { echo 'Switching Ruby failed'; exit 1; }"
|
123
132
|
out << 'cd ext && rm -f libappsignal.a && ruby extconf.rb && make clean && make && cd ..'
|
124
133
|
GEMFILES.each do |gemfile|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
134
|
+
unless EXCLUSIONS[gemfile] && EXCLUSIONS[gemfile].include?(version)
|
135
|
+
out << "echo 'Bundling #{gemfile} in #{version}'"
|
136
|
+
out << "bundle --quiet --gemfile gemfiles/#{gemfile}.gemfile || { echo 'Bundling failed'; exit 1; }"
|
137
|
+
out << "echo 'Running #{gemfile} in #{version}'"
|
138
|
+
out << "env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec || { echo 'Running specs failed'; exit 1; }"
|
139
|
+
end
|
129
140
|
end
|
130
141
|
end
|
131
|
-
out << 'rm .ruby-version'
|
142
|
+
out << 'rm -f .ruby-version'
|
132
143
|
out << "echo 'Successfully ran specs for all environments'"
|
133
144
|
|
134
145
|
script = "bundle_and_spec_all_#{version_manager}.sh"
|
@@ -151,4 +162,14 @@ task :console do
|
|
151
162
|
IRB.start
|
152
163
|
end
|
153
164
|
|
154
|
-
task :
|
165
|
+
task :install_extension do
|
166
|
+
`cd ext && rm -f libappsignal.a && ruby extconf.rb && make clean && make`
|
167
|
+
end
|
168
|
+
|
169
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
170
|
+
t.pattern = Dir.glob('spec/**/*_spec.rb')
|
171
|
+
end
|
172
|
+
|
173
|
+
task :travis => [:install_extension, :rspec]
|
174
|
+
|
175
|
+
task :default => [:generate_bundle_and_spec_all, :spec_all_gemfiles]
|
data/ext/agent.yml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
|
-
:version:
|
2
|
+
:version: 9e5359a
|
3
3
|
:triples:
|
4
4
|
x86_64-linux:
|
5
|
-
:checksum:
|
6
|
-
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
5
|
+
:checksum: cafe3e12730619db156edc7d36ce4c6e7a367fba94dcb509c0373e46beeacc00
|
6
|
+
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/9e5359a/appsignal-agent-x86_64-linux-static.tar.gz
|
7
7
|
:lib_filename: libappsignal.a
|
8
8
|
i686-linux:
|
9
|
-
:checksum:
|
10
|
-
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
9
|
+
:checksum: 4f5453174877e5bbc61e686eadfd741870eb5ed7713a405440ba8cfa77a884d8
|
10
|
+
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/9e5359a/appsignal-agent-i686-linux-static.tar.gz
|
11
11
|
:lib_filename: libappsignal.a
|
12
12
|
x86_64-darwin:
|
13
|
-
:checksum:
|
14
|
-
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
13
|
+
:checksum: 19d974f0ce1c8e1e296f631876f050992b2de055e0f835c07a811da6513c621d
|
14
|
+
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/9e5359a/appsignal-agent-x86_64-darwin-static.tar.gz
|
15
15
|
:lib_filename: libappsignal.a
|
data/ext/appsignal_extension.c
CHANGED
@@ -105,9 +105,11 @@ static VALUE set_transaction_metadata(VALUE self, VALUE transaction_index, VALUE
|
|
105
105
|
}
|
106
106
|
|
107
107
|
static VALUE finish_transaction(VALUE self, VALUE transaction_index) {
|
108
|
+
int sample;
|
109
|
+
|
108
110
|
Check_Type(transaction_index, T_FIXNUM);
|
109
111
|
|
110
|
-
|
112
|
+
sample = appsignal_finish_transaction(FIX2INT(transaction_index));
|
111
113
|
return sample == 1 ? Qtrue : Qfalse;
|
112
114
|
}
|
113
115
|
|
data/gemfiles/rails-4.2.gemfile
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'securerandom'
|
3
3
|
|
4
|
+
# Make sure we have the notification system
|
4
5
|
begin
|
5
6
|
require 'active_support/notifications'
|
6
7
|
ActiveSupport::Notifications::Fanout::Subscribers::Timed # See it it's recent enough
|
7
|
-
rescue LoadError
|
8
|
+
rescue LoadError
|
8
9
|
require 'vendor/active_support/notifications'
|
10
|
+
rescue NameError
|
11
|
+
require 'appsignal/update_active_support'
|
12
|
+
Appsignal::UpdateActiveSupport.run
|
9
13
|
end
|
10
14
|
|
11
15
|
module Appsignal
|
@@ -250,6 +254,7 @@ require 'appsignal/hooks'
|
|
250
254
|
require 'appsignal/marker'
|
251
255
|
require 'appsignal/params_sanitizer'
|
252
256
|
require 'appsignal/integrations/railtie' if defined?(::Rails)
|
257
|
+
require 'appsignal/integrations/resque'
|
253
258
|
require 'appsignal/subscriber'
|
254
259
|
require 'appsignal/transaction'
|
255
260
|
require 'appsignal/version'
|
@@ -6,7 +6,7 @@ module Appsignal
|
|
6
6
|
|
7
7
|
SINGLE_QUOTED_STRING = /'(.?|[^']).*'/.freeze
|
8
8
|
DOUBLE_QUOTED_STRING = /"(.?|[^"]).*"/.freeze
|
9
|
-
IN_OPERATOR_CONTENT = /(IN \()[^\)]+(\))/.freeze
|
9
|
+
IN_OPERATOR_CONTENT = /(IN \()[^SELECT][^\)]+(\))/.freeze
|
10
10
|
NUMERIC = /\d*\.?\d+/.freeze
|
11
11
|
REPLACEMENT = '?'.freeze
|
12
12
|
IN_REPLACEMENT = '\1?\2'.freeze
|
data/lib/appsignal/hooks.rb
CHANGED
@@ -55,7 +55,6 @@ require 'appsignal/hooks/passenger'
|
|
55
55
|
require 'appsignal/hooks/puma'
|
56
56
|
require 'appsignal/hooks/rake'
|
57
57
|
require 'appsignal/hooks/redis'
|
58
|
-
require 'appsignal/hooks/resque'
|
59
58
|
require 'appsignal/hooks/sequel'
|
60
59
|
require 'appsignal/hooks/sidekiq'
|
61
60
|
require 'appsignal/hooks/unicorn'
|
data/lib/appsignal/hooks/rake.rb
CHANGED
@@ -9,18 +9,10 @@ module Appsignal
|
|
9
9
|
|
10
10
|
def install
|
11
11
|
::Rake::Task.class_eval do
|
12
|
-
alias :
|
12
|
+
alias :execute_without_appsignal :execute
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
invoke_with_appsignal(*args)
|
17
|
-
else
|
18
|
-
invoke_without_appsignal(*args)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def invoke_with_appsignal(*args)
|
23
|
-
invoke_without_appsignal(*args)
|
14
|
+
def execute(*args)
|
15
|
+
execute_without_appsignal(*args)
|
24
16
|
rescue => error
|
25
17
|
transaction = Appsignal::Transaction.create(
|
26
18
|
SecureRandom.uuid,
|
@@ -31,7 +23,7 @@ module Appsignal
|
|
31
23
|
)
|
32
24
|
transaction.set_action(name)
|
33
25
|
transaction.set_error(error)
|
34
|
-
transaction.complete
|
26
|
+
transaction.complete
|
35
27
|
Appsignal.stop
|
36
28
|
raise error
|
37
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Integrations
|
3
|
+
module ResquePlugin
|
4
|
+
def around_perform_resque_plugin(*args)
|
5
|
+
Appsignal.monitor_transaction(
|
6
|
+
'perform_job.resque',
|
7
|
+
:class => self.to_s,
|
8
|
+
:method => 'perform'
|
9
|
+
) do
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/appsignal/subscriber.rb
CHANGED
@@ -31,14 +31,14 @@ module Appsignal
|
|
31
31
|
|
32
32
|
def start(name, id, payload)
|
33
33
|
return unless transaction = Appsignal::Transaction.current
|
34
|
-
return if transaction.paused?
|
34
|
+
return if transaction.nil_transaction? || transaction.paused?
|
35
35
|
|
36
36
|
Appsignal::Extension.start_event(transaction.transaction_index)
|
37
37
|
end
|
38
38
|
|
39
39
|
def finish(name, id, payload)
|
40
40
|
return unless transaction = Appsignal::Transaction.current
|
41
|
-
return if transaction.paused?
|
41
|
+
return if transaction.nil_transaction? || transaction.paused?
|
42
42
|
|
43
43
|
title, body = Appsignal::EventFormatter.format(name, payload)
|
44
44
|
Appsignal::Extension.finish_event(
|
@@ -21,16 +21,12 @@ module Appsignal
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def current
|
24
|
-
Thread.current[:appsignal_transaction]
|
24
|
+
Thread.current[:appsignal_transaction] || NilTransaction.new
|
25
25
|
end
|
26
26
|
|
27
27
|
def complete_current!
|
28
|
-
|
29
|
-
|
30
|
-
Thread.current[:appsignal_transaction] = nil
|
31
|
-
else
|
32
|
-
Appsignal.logger.error('Trying to complete current, but no transaction present')
|
33
|
-
end
|
28
|
+
current.complete
|
29
|
+
Thread.current[:appsignal_transaction] = nil
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
@@ -49,6 +45,10 @@ module Appsignal
|
|
49
45
|
@transaction_index = Appsignal::Extension.start_transaction(@transaction_id, @namespace)
|
50
46
|
end
|
51
47
|
|
48
|
+
def nil_transaction?
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
52
|
def complete
|
53
53
|
if Appsignal::Extension.finish_transaction(transaction_index)
|
54
54
|
sample_data
|
@@ -230,5 +230,16 @@ module Appsignal
|
|
230
230
|
backtrace
|
231
231
|
end
|
232
232
|
end
|
233
|
+
|
234
|
+
# Stub that is returned by `Transaction.current` if there is no current transaction, so
|
235
|
+
# that it's still safe to call methods on it if there is none.
|
236
|
+
class NilTransaction
|
237
|
+
def method_missing(m, *args, &block)
|
238
|
+
end
|
239
|
+
|
240
|
+
def nil_transaction?
|
241
|
+
true
|
242
|
+
end
|
243
|
+
end
|
233
244
|
end
|
234
245
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module UpdateActiveSupport
|
3
|
+
def self.run
|
4
|
+
# Get the old subscribers if present
|
5
|
+
old_notifier = ActiveSupport::Notifications.notifier
|
6
|
+
subscribers = old_notifier.instance_variable_get('@subscribers') || []
|
7
|
+
|
8
|
+
# Require the newer notifications
|
9
|
+
require 'vendor/active_support/notifications'
|
10
|
+
|
11
|
+
# Re-subscribe the old subscribers
|
12
|
+
subscribers.each do |sub|
|
13
|
+
pattern = sub.instance_variable_get('@pattern')
|
14
|
+
delegate = sub.instance_variable_get('@delegate')
|
15
|
+
next unless pattern && delegate
|
16
|
+
ActiveSupport::Notifications.subscribe(pattern, delegate)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -90,11 +90,17 @@ if active_record_present?
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
context "in operator with
|
93
|
+
context "in operator with values" do
|
94
94
|
let(:sql) { 'SELECT `table`.* FROM `table` WHERE `id` IN (1, 2)' }
|
95
95
|
|
96
96
|
it { should == ['Model load', 'SELECT `table`.* FROM `table` WHERE `id` IN (?)'] }
|
97
97
|
end
|
98
|
+
|
99
|
+
context "in operator with inner query" do
|
100
|
+
let(:sql) { 'SELECT `table`.* FROM `table` WHERE `id` IN (SELECT `id` from `other_table` WHERE `value` = 10.0)' }
|
101
|
+
|
102
|
+
it { should == ['Model load', 'SELECT `table`.* FROM `table` WHERE `id` IN (SELECT `id` from `other_table` WHERE `value` = ?)'] }
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
context "with double quote style table names" do
|
@@ -6,51 +6,29 @@ describe Appsignal::Hooks::RakeHook do
|
|
6
6
|
let(:task) { Rake::Task.new('task', app) }
|
7
7
|
before do
|
8
8
|
task.stub(
|
9
|
-
:name
|
10
|
-
:
|
9
|
+
:name => 'task:name',
|
10
|
+
:execute_without_appsignal => true
|
11
11
|
)
|
12
12
|
end
|
13
13
|
before :all do
|
14
14
|
Appsignal::Hooks::RakeHook.new.install
|
15
15
|
end
|
16
16
|
|
17
|
-
describe "#
|
18
|
-
before { Appsignal.stub(:active? => true) }
|
19
|
-
|
20
|
-
it "should call with appsignal monitoring" do
|
21
|
-
expect( task ).to receive(:invoke_with_appsignal).with(['foo'])
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when not active" do
|
25
|
-
before { Appsignal.stub(:active? => false) }
|
26
|
-
|
27
|
-
it "should NOT call with appsignal monitoring" do
|
28
|
-
expect( task ).to_not receive(:invoke_with_appsignal).with(['foo'])
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should call the original task" do
|
32
|
-
expect( task ).to receive(:invoke_without_appsignal).with(['foo'])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
after { task.invoke(['foo']) }
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#invoke_with_appsignal" do
|
17
|
+
describe "#execute" do
|
40
18
|
context "with transaction" do
|
41
19
|
let!(:transaction) { regular_transaction }
|
42
20
|
let!(:agent) { double('Agent', :send_queue => true) }
|
43
21
|
before do
|
44
22
|
transaction.stub(:set_action)
|
45
23
|
transaction.stub(:set_error)
|
46
|
-
transaction.stub(:complete
|
24
|
+
transaction.stub(:complete)
|
47
25
|
SecureRandom.stub(:uuid => '123')
|
48
26
|
Appsignal::Transaction.stub(:create => transaction)
|
49
27
|
Appsignal.stub(:active? => true)
|
50
28
|
end
|
51
29
|
|
52
30
|
it "should call the original task" do
|
53
|
-
expect( task ).to receive(:
|
31
|
+
expect( task ).to receive(:execute_without_appsignal).with('foo')
|
54
32
|
end
|
55
33
|
|
56
34
|
it "should not create a transaction" do
|
@@ -61,7 +39,7 @@ describe Appsignal::Hooks::RakeHook do
|
|
61
39
|
let(:exception) { VerySpecificError.new }
|
62
40
|
|
63
41
|
before do
|
64
|
-
task.stub(:
|
42
|
+
task.stub(:execute_without_appsignal).and_raise(exception)
|
65
43
|
end
|
66
44
|
|
67
45
|
it "should create a transaction" do
|
@@ -81,7 +59,7 @@ describe Appsignal::Hooks::RakeHook do
|
|
81
59
|
end
|
82
60
|
|
83
61
|
it "should call complete! on the transaction" do
|
84
|
-
expect( transaction ).to receive(:complete
|
62
|
+
expect( transaction ).to receive(:complete)
|
85
63
|
end
|
86
64
|
|
87
65
|
it "should stop appsignal" do
|
@@ -90,6 +68,6 @@ describe Appsignal::Hooks::RakeHook do
|
|
90
68
|
end
|
91
69
|
end
|
92
70
|
|
93
|
-
after { task.
|
71
|
+
after { task.execute('foo') rescue VerySpecificError }
|
94
72
|
end
|
95
73
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if resque_present?
|
4
|
+
describe "Resque integration" do
|
5
|
+
let(:file) { File.expand_path('lib/appsignal/integrations/resque.rb') }
|
6
|
+
|
7
|
+
context "with resque" do
|
8
|
+
before do
|
9
|
+
load file
|
10
|
+
start_agent
|
11
|
+
|
12
|
+
class TestJob
|
13
|
+
extend Appsignal::Integrations::ResquePlugin
|
14
|
+
|
15
|
+
def self.perform
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class BrokenTestJob
|
20
|
+
extend Appsignal::Integrations::ResquePlugin
|
21
|
+
|
22
|
+
def self.perform
|
23
|
+
raise VerySpecificError.new('broken')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :around_perform_resque_plugin do
|
29
|
+
let(:transaction) { Appsignal::Transaction.new('1', 'background', {}, {}) }
|
30
|
+
let(:job) { Resque::Job.new('default', {'class' => 'TestJob'}) }
|
31
|
+
before do
|
32
|
+
transaction.stub(:complete => true)
|
33
|
+
Appsignal::Transaction.stub(:current => transaction)
|
34
|
+
end
|
35
|
+
|
36
|
+
context "without exception" do
|
37
|
+
it "should create a new transaction" do
|
38
|
+
Appsignal::Transaction.should_receive(:create).and_return(transaction)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should wrap in a transaction with the correct params" do
|
42
|
+
Appsignal.should_receive(:monitor_transaction).with(
|
43
|
+
'perform_job.resque',
|
44
|
+
:class => 'TestJob',
|
45
|
+
:method => 'perform'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should close the transaction" do
|
50
|
+
transaction.should_receive(:complete)
|
51
|
+
end
|
52
|
+
|
53
|
+
after { job.perform }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with exception" do
|
57
|
+
let(:job) { Resque::Job.new('default', {'class' => 'BrokenTestJob'}) }
|
58
|
+
|
59
|
+
it "should set the exception" do
|
60
|
+
Appsignal::Transaction.any_instance.should_receive(:set_error)
|
61
|
+
end
|
62
|
+
|
63
|
+
after do
|
64
|
+
begin
|
65
|
+
job.perform
|
66
|
+
rescue VerySpecificError
|
67
|
+
# Do nothing
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "without resque" do
|
75
|
+
before(:all) { Object.send(:remove_const, :Resque) }
|
76
|
+
|
77
|
+
specify { expect { ::Resque }.to raise_error(NameError) }
|
78
|
+
specify { expect { load file }.to_not raise_error }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -40,33 +40,44 @@ describe Appsignal::Transaction do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe '.current' do
|
43
|
-
before { transaction }
|
44
43
|
subject { Appsignal::Transaction.current }
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
45
|
+
context "if there is a transaction" do
|
46
|
+
before { transaction }
|
50
47
|
|
51
|
-
|
52
|
-
|
48
|
+
it "should return the correct transaction" do
|
49
|
+
should == transaction
|
50
|
+
end
|
53
51
|
|
54
|
-
|
55
|
-
|
52
|
+
it "should indicate it's not a nil transaction" do
|
53
|
+
subject.nil_transaction?.should be_false
|
54
|
+
end
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
context "if there is no transaction" do
|
58
|
+
before do
|
59
|
+
Thread.current[:appsignal_transaction] = nil
|
60
|
+
end
|
59
61
|
|
60
|
-
|
62
|
+
it "should return a nil transaction stub" do
|
63
|
+
should be_a Appsignal::Transaction::NilTransaction
|
64
|
+
end
|
61
65
|
|
62
|
-
|
66
|
+
it "should indicate it's a nil transaction" do
|
67
|
+
subject.nil_transaction?.should be_true
|
63
68
|
end
|
64
69
|
end
|
70
|
+
end
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
72
|
+
describe "complete_current!" do
|
73
|
+
before { Appsignal::Transaction.create('2', Appsignal::Transaction::HTTP_REQUEST, {}) }
|
74
|
+
|
75
|
+
it "should complete the current transaction and set the thread appsignal_transaction to nil" do
|
76
|
+
Appsignal::Extension.should_receive(:finish_transaction).with(kind_of(Integer))
|
77
|
+
|
78
|
+
Appsignal::Transaction.complete_current!
|
79
|
+
|
80
|
+
Thread.current[:appsignal_transaction].should be_nil
|
70
81
|
end
|
71
82
|
end
|
72
83
|
end
|
@@ -587,7 +598,7 @@ describe Appsignal::Transaction do
|
|
587
598
|
def load_session(env); [1, {:foo => :bar}]; end
|
588
599
|
def session_exists?(env); true; end
|
589
600
|
}.new
|
590
|
-
ActionDispatch::Request::Session.create(store,
|
601
|
+
ActionDispatch::Request::Session.create(store, ActionDispatch::Request.new('rack.input' => StringIO.new), {})
|
591
602
|
end
|
592
603
|
end
|
593
604
|
end
|
@@ -641,4 +652,27 @@ describe Appsignal::Transaction do
|
|
641
652
|
pending "calls Rails backtrace cleaner if Rails is present"
|
642
653
|
end
|
643
654
|
end
|
655
|
+
|
656
|
+
describe Appsignal::Transaction::NilTransaction do
|
657
|
+
subject { Appsignal::Transaction::NilTransaction.new }
|
658
|
+
|
659
|
+
it "should have method stubs" do
|
660
|
+
lambda {
|
661
|
+
subject.complete
|
662
|
+
subject.pause!
|
663
|
+
subject.resume!
|
664
|
+
subject.paused?
|
665
|
+
subject.store(:key)
|
666
|
+
subject.set_tags(:tag => 1)
|
667
|
+
subject.set_action('action')
|
668
|
+
subject.set_http_or_background_action
|
669
|
+
subject.set_queue_start(1)
|
670
|
+
subject.set_http_or_background_queue_start
|
671
|
+
subject.set_metadata('key', 'value')
|
672
|
+
subject.set_sample_data('key', 'data')
|
673
|
+
subject.sample_data
|
674
|
+
subject.set_error('a')
|
675
|
+
}.should_not raise_error
|
676
|
+
end
|
677
|
+
end
|
644
678
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Appsignal::UpdateActiveSupport', :if => (
|
4
|
+
Gem.loaded_specs['rails'] &&
|
5
|
+
Gem.loaded_specs['rails'].version < Gem::Version.create('4.0')
|
6
|
+
) do
|
7
|
+
require 'appsignal/update_active_support'
|
8
|
+
let(:pattern) { 'foo' }
|
9
|
+
let(:delegate) { double }
|
10
|
+
before { ActiveSupport::Notifications.subscribe(pattern, delegate) }
|
11
|
+
|
12
|
+
it "should transfer old subscriptions to the new version" do
|
13
|
+
expect( ActiveSupport::Notifications ).to receive(:subscribe).with(pattern, delegate)
|
14
|
+
end
|
15
|
+
|
16
|
+
after { Appsignal::UpdateActiveSupport.run }
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 1.0.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -140,6 +140,8 @@ files:
|
|
140
140
|
- gemfiles/rails-4.0.gemfile
|
141
141
|
- gemfiles/rails-4.1.gemfile
|
142
142
|
- gemfiles/rails-4.2.gemfile
|
143
|
+
- gemfiles/rails-5.0.gemfile
|
144
|
+
- gemfiles/resque.gemfile
|
143
145
|
- gemfiles/sequel.gemfile
|
144
146
|
- gemfiles/sinatra.gemfile
|
145
147
|
- lib/appsignal.rb
|
@@ -162,7 +164,6 @@ files:
|
|
162
164
|
- lib/appsignal/hooks/puma.rb
|
163
165
|
- lib/appsignal/hooks/rake.rb
|
164
166
|
- lib/appsignal/hooks/redis.rb
|
165
|
-
- lib/appsignal/hooks/resque.rb
|
166
167
|
- lib/appsignal/hooks/sequel.rb
|
167
168
|
- lib/appsignal/hooks/sidekiq.rb
|
168
169
|
- lib/appsignal/hooks/unicorn.rb
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- lib/appsignal/integrations/mongo_ruby_driver.rb
|
174
175
|
- lib/appsignal/integrations/padrino.rb
|
175
176
|
- lib/appsignal/integrations/railtie.rb
|
177
|
+
- lib/appsignal/integrations/resque.rb
|
176
178
|
- lib/appsignal/integrations/sinatra.rb
|
177
179
|
- lib/appsignal/js_exception_transaction.rb
|
178
180
|
- lib/appsignal/marker.rb
|
@@ -184,6 +186,7 @@ files:
|
|
184
186
|
- lib/appsignal/subscriber.rb
|
185
187
|
- lib/appsignal/transaction.rb
|
186
188
|
- lib/appsignal/transmitter.rb
|
189
|
+
- lib/appsignal/update_active_support.rb
|
187
190
|
- lib/appsignal/utils.rb
|
188
191
|
- lib/appsignal/version.rb
|
189
192
|
- lib/generators/appsignal/USAGE
|
@@ -214,7 +217,6 @@ files:
|
|
214
217
|
- spec/lib/appsignal/hooks/puma_spec.rb
|
215
218
|
- spec/lib/appsignal/hooks/rake_spec.rb
|
216
219
|
- spec/lib/appsignal/hooks/redis_spec.rb
|
217
|
-
- spec/lib/appsignal/hooks/resque_spec.rb
|
218
220
|
- spec/lib/appsignal/hooks/sequel_spec.rb
|
219
221
|
- spec/lib/appsignal/hooks/sidekiq_spec.rb
|
220
222
|
- spec/lib/appsignal/hooks/unicorn_spec.rb
|
@@ -222,6 +224,7 @@ files:
|
|
222
224
|
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
223
225
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
224
226
|
- spec/lib/appsignal/integrations/railtie_spec.rb
|
227
|
+
- spec/lib/appsignal/integrations/resque_spec.rb
|
225
228
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
226
229
|
- spec/lib/appsignal/js_exception_transaction_spec.rb
|
227
230
|
- spec/lib/appsignal/marker_spec.rb
|
@@ -233,6 +236,7 @@ files:
|
|
233
236
|
- spec/lib/appsignal/subscriber_spec.rb
|
234
237
|
- spec/lib/appsignal/transaction_spec.rb
|
235
238
|
- spec/lib/appsignal/transmitter_spec.rb
|
239
|
+
- spec/lib/appsignal/update_active_support_spec.rb
|
236
240
|
- spec/lib/appsignal/utils_spec.rb
|
237
241
|
- spec/lib/appsignal_spec.rb
|
238
242
|
- spec/lib/generators/appsignal/appsignal_generator_spec.rb
|
@@ -271,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
275
|
version: 1.3.1
|
272
276
|
requirements: []
|
273
277
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.
|
278
|
+
rubygems_version: 2.2.5
|
275
279
|
signing_key:
|
276
280
|
specification_version: 4
|
277
281
|
summary: Logs performance and exception data from your app to appsignal.com
|
@@ -295,7 +299,6 @@ test_files:
|
|
295
299
|
- spec/lib/appsignal/hooks/puma_spec.rb
|
296
300
|
- spec/lib/appsignal/hooks/rake_spec.rb
|
297
301
|
- spec/lib/appsignal/hooks/redis_spec.rb
|
298
|
-
- spec/lib/appsignal/hooks/resque_spec.rb
|
299
302
|
- spec/lib/appsignal/hooks/sequel_spec.rb
|
300
303
|
- spec/lib/appsignal/hooks/sidekiq_spec.rb
|
301
304
|
- spec/lib/appsignal/hooks/unicorn_spec.rb
|
@@ -303,6 +306,7 @@ test_files:
|
|
303
306
|
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
304
307
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
305
308
|
- spec/lib/appsignal/integrations/railtie_spec.rb
|
309
|
+
- spec/lib/appsignal/integrations/resque_spec.rb
|
306
310
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
307
311
|
- spec/lib/appsignal/js_exception_transaction_spec.rb
|
308
312
|
- spec/lib/appsignal/marker_spec.rb
|
@@ -314,6 +318,7 @@ test_files:
|
|
314
318
|
- spec/lib/appsignal/subscriber_spec.rb
|
315
319
|
- spec/lib/appsignal/transaction_spec.rb
|
316
320
|
- spec/lib/appsignal/transmitter_spec.rb
|
321
|
+
- spec/lib/appsignal/update_active_support_spec.rb
|
317
322
|
- spec/lib/appsignal/utils_spec.rb
|
318
323
|
- spec/lib/appsignal_spec.rb
|
319
324
|
- spec/lib/generators/appsignal/appsignal_generator_spec.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Appsignal
|
2
|
-
class Hooks
|
3
|
-
module ResquePlugin
|
4
|
-
def around_perform_resque_plugin(*args)
|
5
|
-
Appsignal.monitor_single_transaction(
|
6
|
-
'perform_job.resque',
|
7
|
-
:class => self.to_s,
|
8
|
-
:method => 'perform'
|
9
|
-
) do
|
10
|
-
yield
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class ResqueHook < Appsignal::Hooks::Hook
|
16
|
-
register :resque
|
17
|
-
|
18
|
-
def dependencies_present?
|
19
|
-
defined?(::Resque)
|
20
|
-
end
|
21
|
-
|
22
|
-
def install
|
23
|
-
# Extend the default job class with AppSignal instrumentation
|
24
|
-
::Resque::Job.send(:extend, Appsignal::Hooks::ResquePlugin)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Appsignal::Hooks::ResqueHook do
|
4
|
-
context "with resque" do
|
5
|
-
before :all do
|
6
|
-
module Resque
|
7
|
-
def self.before_first_fork
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.after_fork
|
11
|
-
end
|
12
|
-
|
13
|
-
class Job
|
14
|
-
end
|
15
|
-
|
16
|
-
class TestError < StandardError
|
17
|
-
end
|
18
|
-
end
|
19
|
-
Appsignal::Hooks::ResqueHook.new.install
|
20
|
-
start_agent
|
21
|
-
end
|
22
|
-
after(:all) { Object.send(:remove_const, :Resque) }
|
23
|
-
|
24
|
-
describe :around_perform_resque_plugin do
|
25
|
-
let(:transaction) { background_job_transaction }
|
26
|
-
let(:job) { Resque::Job }
|
27
|
-
let(:invoked_job) { nil }
|
28
|
-
before do
|
29
|
-
transaction.stub(:complete! => true)
|
30
|
-
Appsignal::Transaction.stub(:current => transaction)
|
31
|
-
end
|
32
|
-
|
33
|
-
context "without exception" do
|
34
|
-
it "should create a new transaction" do
|
35
|
-
Appsignal::Transaction.should_receive(:create).and_return(transaction)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should wrap in a transaction with the correct params" do
|
39
|
-
Appsignal.should_receive(:monitor_single_transaction).with(
|
40
|
-
'perform_job.resque',
|
41
|
-
:class => 'Resque::Job',
|
42
|
-
:method => 'perform'
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should close the transaction" do
|
47
|
-
Appsignal::Transaction.should_receive(:complete_current!)
|
48
|
-
end
|
49
|
-
|
50
|
-
after { job.around_perform_resque_plugin { invoked_job } }
|
51
|
-
end
|
52
|
-
|
53
|
-
context "with exception" do
|
54
|
-
it "should set the exception" do
|
55
|
-
Appsignal::Transaction.any_instance.should_receive(:set_error)
|
56
|
-
end
|
57
|
-
|
58
|
-
after do
|
59
|
-
begin
|
60
|
-
job.around_perform_resque_plugin { raise(Resque::TestError.new('the roof')) }
|
61
|
-
rescue Resque::TestError
|
62
|
-
# Do nothing
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "without resque" do
|
70
|
-
its(:dependencies_present?) { should be_false }
|
71
|
-
end
|
72
|
-
end
|