appsignal 0.7.1 → 0.8.0.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -0
- data/CHANGELOG.md +3 -0
- data/README.md +2 -0
- data/Rakefile +16 -12
- data/appsignal.gemspec +1 -0
- data/gemfiles/rails-4.1.gemfile +7 -0
- data/lib/appsignal.rb +1 -0
- data/lib/appsignal/agent.rb +2 -0
- data/lib/appsignal/integrations/sidekiq.rb +35 -0
- data/lib/appsignal/transaction.rb +19 -4
- data/lib/appsignal/transaction/formatter.rb +8 -5
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/agent_spec.rb +33 -22
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +79 -0
- data/spec/lib/appsignal/transaction/formatter_spec.rb +23 -0
- data/spec/lib/appsignal/transaction_spec.rb +53 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/support/helpers/notification_helpers.rb +11 -0
- data/spec/support/helpers/transaction_helpers.rb +17 -0
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTVhMjJhZmE1M2Y3ZTNmNzhhNjdlNDU1ZDRiN2ZkN2M5YmZhZjUwNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODVhZDM0M2FhMTkxNzgxZWI1NDBhNDI4YWNlMjJkMjBlNDE5ZmRlZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzNjMmVhNzY2ZmNhNmFjMDc3NWM4YjA5YzQxYzc0YzkzMDVkOGI2NDc3MGVk
|
10
|
+
MzI4N2NjMDMwODVjZGRhZTczNWI4MTkzZjViMzRjNmVjMmQ3MTk3NTZjY2E0
|
11
|
+
OTQxOTFlOWNkMWVkOWMyNDI1ZDhhNjRlNGFjZjIwMmU2MDcxNmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjZmMjExNzFhZTZlNzE2OWFjZmJmNTdkMTYwZmQ3NTNjOTZkNTQxMzhmMTA1
|
14
|
+
ZDU0ZDhlOTM1NDBiN2U3YTAzNzc1YWQ1YTFlMTg1Y2JiYzBmMWM4NWYxMzAy
|
15
|
+
NDYyM2RkNTU2YzI1YzgzMDYwZTE5ZjgzYzJlN2Y0YmUwYjBjNGQ=
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,7 @@ bundle --gemfile gemfiles/rails-3.0.gemfile
|
|
63
63
|
bundle --gemfile gemfiles/rails-3.1.gemfile
|
64
64
|
bundle --gemfile gemfiles/rails-3.2.gemfile
|
65
65
|
bundle --gemfile gemfiles/rails-4.0.gemfile
|
66
|
+
bundle --gemfile gemfiles/rails-4.1.gemfile
|
66
67
|
bundle --gemfile gemfiles/sinatra.gemfile
|
67
68
|
```
|
68
69
|
|
@@ -74,6 +75,7 @@ BUNDLE_GEMFILE=gemfiles/rails-3.0.gemfile bundle exec rspec
|
|
74
75
|
BUNDLE_GEMFILE=gemfiles/rails-3.1.gemfile bundle exec rspec
|
75
76
|
BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec
|
76
77
|
BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec
|
78
|
+
BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec
|
77
79
|
BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec
|
78
80
|
```
|
79
81
|
|
data/Rakefile
CHANGED
@@ -59,30 +59,34 @@ task :publish do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
task :bundle do
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
system 'bundle --gemfile gemfiles/no_dependencies.gemfile'
|
63
|
+
system 'bundle --gemfile gemfiles/rails-3.0.gemfile'
|
64
|
+
system 'bundle --gemfile gemfiles/rails-3.1.gemfile'
|
65
|
+
system 'bundle --gemfile gemfiles/rails-3.2.gemfile'
|
66
|
+
system 'bundle --gemfile gemfiles/rails-4.0.gemfile'
|
67
|
+
system 'bundle --gemfile gemfiles/rails-4.1.gemfile'
|
68
|
+
system 'bundle --gemfile gemfiles/sinatra.gemfile'
|
68
69
|
end
|
69
70
|
|
70
71
|
task :spec do
|
71
72
|
puts 'Running no dependencies'
|
72
|
-
|
73
|
+
system 'env BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec'
|
73
74
|
|
74
75
|
puts 'Running rails-3.0'
|
75
|
-
|
76
|
+
system 'env BUNDLE_GEMFILE=gemfiles/rails-3.0.gemfile bundle exec rspec'
|
76
77
|
|
77
78
|
puts 'Running rails-3.1'
|
78
|
-
|
79
|
+
system 'env BUNDLE_GEMFILE=gemfiles/rails-3.1.gemfile bundle exec rspec'
|
79
80
|
|
80
81
|
puts 'Running rails-3.2'
|
81
|
-
|
82
|
+
system 'env BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec'
|
82
83
|
|
83
84
|
puts 'Running rails-4.0'
|
84
|
-
|
85
|
+
system 'env BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec'
|
86
|
+
|
87
|
+
puts 'Running rails-4.1'
|
88
|
+
system 'env BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec'
|
85
89
|
|
86
90
|
puts 'Running sinatra'
|
87
|
-
|
91
|
+
system 'env BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec'
|
88
92
|
end
|
data/appsignal.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |gem|
|
|
32
32
|
gem.add_development_dependency 'rspec'
|
33
33
|
gem.add_development_dependency 'capistrano', '< 3.0'
|
34
34
|
gem.add_development_dependency 'pry'
|
35
|
+
gem.add_development_dependency 'timecop'
|
35
36
|
|
36
37
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
37
38
|
gem.add_development_dependency 'racc'
|
data/lib/appsignal.rb
CHANGED
data/lib/appsignal/agent.rb
CHANGED
@@ -45,6 +45,8 @@ module Appsignal
|
|
45
45
|
event = ActiveSupport::Notifications::Event.new(*args)
|
46
46
|
if event.name.start_with?('process_action')
|
47
47
|
Appsignal::Transaction.current.set_process_action_event(event)
|
48
|
+
elsif event.name.start_with?('perform_job')
|
49
|
+
Appsignal::Transaction.current.set_perform_job_event(event)
|
48
50
|
end
|
49
51
|
Appsignal::Transaction.current.add_event(event)
|
50
52
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
if defined?(::Sidekiq)
|
2
|
+
module Appsignal
|
3
|
+
module Integrations
|
4
|
+
class SidekiqPlugin
|
5
|
+
def call(worker, item, queue)
|
6
|
+
Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)
|
7
|
+
|
8
|
+
ActiveSupport::Notifications.instrument(
|
9
|
+
'perform_job.sidekiq',
|
10
|
+
:class => item['class'],
|
11
|
+
:method => 'perform',
|
12
|
+
:attempts => item['retry_count'],
|
13
|
+
:queue => item['queue'],
|
14
|
+
:queue_time => (Time.now.to_f - item['enqueued_at'].to_f) * 1000
|
15
|
+
) do
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
rescue Exception => exception
|
19
|
+
unless Appsignal.is_ignored_exception?(exception)
|
20
|
+
Appsignal::Transaction.current.add_exception(exception)
|
21
|
+
end
|
22
|
+
raise exception
|
23
|
+
ensure
|
24
|
+
Appsignal::Transaction.current.complete!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Sidekiq.configure_server do |config|
|
31
|
+
config.server_middleware do |chain|
|
32
|
+
chain.add Appsignal::Integrations::SidekiqPlugin
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -22,7 +22,7 @@ module Appsignal
|
|
22
22
|
end
|
23
23
|
|
24
24
|
attr_reader :request_id, :events, :process_action_event, :action, :exception,
|
25
|
-
:env, :fullpath, :time, :tags
|
25
|
+
:env, :fullpath, :time, :tags, :kind
|
26
26
|
|
27
27
|
def initialize(request_id, env)
|
28
28
|
@request_id = request_id
|
@@ -51,9 +51,16 @@ module Appsignal
|
|
51
51
|
|
52
52
|
def set_process_action_event(event)
|
53
53
|
@process_action_event = event
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
return unless event && event.payload
|
55
|
+
@action = "#{event.payload[:controller]}##{event.payload[:action]}"
|
56
|
+
@kind = 'http_request'
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_perform_job_event(event)
|
60
|
+
@process_action_event = event
|
61
|
+
return unless event && event.payload
|
62
|
+
@action = "#{event.payload[:class]}##{event.payload[:method]}"
|
63
|
+
@kind = 'background_job'
|
57
64
|
end
|
58
65
|
|
59
66
|
def add_event(event)
|
@@ -114,6 +121,14 @@ module Appsignal
|
|
114
121
|
end
|
115
122
|
end
|
116
123
|
|
124
|
+
def queue_start
|
125
|
+
if @kind == 'background_job'
|
126
|
+
@process_action_event.payload[:queue_start].to_f
|
127
|
+
else
|
128
|
+
http_queue_start
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
117
132
|
def http_queue_start
|
118
133
|
return unless env
|
119
134
|
env_var = env['HTTP_X_QUEUE_START'] || env['HTTP_X_REQUEST_START']
|
@@ -9,7 +9,7 @@ module Appsignal
|
|
9
9
|
|
10
10
|
def to_hash
|
11
11
|
merge_process_action_event_with_log_entry! if process_action_event
|
12
|
-
|
12
|
+
add_queue_duration_to_hash!
|
13
13
|
if exception?
|
14
14
|
add_exception_to_hash!
|
15
15
|
add_tags_to_hash!
|
@@ -25,7 +25,7 @@ module Appsignal
|
|
25
25
|
:request_id => request_id,
|
26
26
|
:log_entry => {
|
27
27
|
:path => fullpath,
|
28
|
-
:kind =>
|
28
|
+
:kind => kind,
|
29
29
|
:time => time,
|
30
30
|
:environment => sanitized_environment,
|
31
31
|
:session_data => sanitized_session_data
|
@@ -38,15 +38,18 @@ module Appsignal
|
|
38
38
|
hash[:log_entry].merge!(event_to_hash(process_action_event))
|
39
39
|
hash[:log_entry].tap do |o|
|
40
40
|
o.merge!(o.delete(:payload))
|
41
|
-
o.delete(:action)
|
42
41
|
o.delete(:controller)
|
42
|
+
o.delete(:action)
|
43
43
|
o.delete(:name)
|
44
|
+
o.delete(:class)
|
45
|
+
o.delete(:method)
|
46
|
+
o.delete(:queue_start)
|
44
47
|
o[:action] = action
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|
48
|
-
def
|
49
|
-
start =
|
51
|
+
def add_queue_duration_to_hash!
|
52
|
+
start = queue_start
|
50
53
|
if start
|
51
54
|
hash[:log_entry][:queue_duration] = hash[:log_entry][:time] - start
|
52
55
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -95,14 +95,14 @@ describe Appsignal::Agent do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should should not listen to events that start with a bang" do
|
98
|
-
Appsignal::Transaction.current.
|
98
|
+
Appsignal::Transaction.current.should_not_receive(:add_event)
|
99
99
|
|
100
100
|
ActiveSupport::Notifications.instrument '!render_template'
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should add a normal event" do
|
104
|
-
Appsignal::Transaction.current.
|
105
|
-
Appsignal::Transaction.current.
|
104
|
+
Appsignal::Transaction.current.should_not_receive(:set_process_action_event)
|
105
|
+
Appsignal::Transaction.current.should_receive(:add_event).with(
|
106
106
|
kind_of(ActiveSupport::Notifications::Event)
|
107
107
|
).at_least(:once)
|
108
108
|
|
@@ -110,15 +110,26 @@ describe Appsignal::Agent do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should add and set a process action event" do
|
113
|
-
Appsignal::Transaction.current.
|
113
|
+
Appsignal::Transaction.current.should_receive(:set_process_action_event).with(
|
114
114
|
kind_of(ActiveSupport::Notifications::Event)
|
115
115
|
).at_least(:once)
|
116
|
-
Appsignal::Transaction.current.
|
116
|
+
Appsignal::Transaction.current.should_receive(:add_event).with(
|
117
117
|
kind_of(ActiveSupport::Notifications::Event)
|
118
118
|
).at_least(:once)
|
119
119
|
|
120
120
|
ActiveSupport::Notifications.instrument 'process_action.rack'
|
121
121
|
end
|
122
|
+
|
123
|
+
it "should add and set a perform job event" do
|
124
|
+
Appsignal::Transaction.current.should_receive(:set_perform_job_event).with(
|
125
|
+
kind_of(ActiveSupport::Notifications::Event)
|
126
|
+
).at_least(:once)
|
127
|
+
Appsignal::Transaction.current.should_receive(:add_event).with(
|
128
|
+
kind_of(ActiveSupport::Notifications::Event)
|
129
|
+
).at_least(:once)
|
130
|
+
|
131
|
+
ActiveSupport::Notifications.instrument 'perform_job.processor'
|
132
|
+
end
|
122
133
|
end
|
123
134
|
end
|
124
135
|
|
@@ -171,6 +182,21 @@ describe Appsignal::Agent do
|
|
171
182
|
after { subject.send_queue }
|
172
183
|
end
|
173
184
|
|
185
|
+
describe "#forked!" do
|
186
|
+
its(:forked?) { should be_false }
|
187
|
+
|
188
|
+
it "should create a new aggregator and restart the thread" do
|
189
|
+
previous_aggregator = subject.aggregator
|
190
|
+
subject.should_receive(:restart_thread)
|
191
|
+
|
192
|
+
subject.forked!
|
193
|
+
|
194
|
+
subject.forked?.should be_true
|
195
|
+
subject.aggregator.should_not == previous_aggregator
|
196
|
+
subject.aggregator.should be_a Appsignal::Aggregator
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
174
200
|
describe "#shutdown" do
|
175
201
|
before do
|
176
202
|
ActiveSupport::Notifications.should_receive(:unsubscribe).with(subject.subscriber)
|
@@ -211,15 +237,6 @@ describe Appsignal::Agent do
|
|
211
237
|
subject.shutdown(true)
|
212
238
|
end
|
213
239
|
end
|
214
|
-
|
215
|
-
context "when we're a child process" do
|
216
|
-
it "should shutdown" do
|
217
|
-
subject.stub(:forked? => true)
|
218
|
-
subject.should_not_receive(:send_queue)
|
219
|
-
|
220
|
-
subject.shutdown(true)
|
221
|
-
end
|
222
|
-
end
|
223
240
|
end
|
224
241
|
end
|
225
242
|
|
@@ -298,16 +315,10 @@ describe Appsignal::Agent do
|
|
298
315
|
end
|
299
316
|
end
|
300
317
|
|
301
|
-
|
302
|
-
it "does not raise exceptions" do
|
303
|
-
expect { subject.send(:shutdown) }.not_to raise_error
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
describe "when inactive" do
|
318
|
+
context "when inactive" do
|
308
319
|
before { Appsignal.stub(:active? => false) }
|
309
320
|
|
310
|
-
it "should not start a
|
321
|
+
it "should not start a thread" do
|
311
322
|
Thread.should_not_receive(:new)
|
312
323
|
end
|
313
324
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class VerySpecificError < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "Sidekiq integration" do
|
7
|
+
let(:file) { File.expand_path('lib/appsignal/integrations/sidekiq.rb') }
|
8
|
+
before :all do
|
9
|
+
module Sidekiq
|
10
|
+
def self.configure_server
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
before do
|
15
|
+
load file
|
16
|
+
start_agent
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:worker) { double }
|
20
|
+
let(:queue) { double }
|
21
|
+
let(:current_transaction) { Appsignal::Transaction.create(SecureRandom.uuid, {}) }
|
22
|
+
let(:item) {{
|
23
|
+
'class' => 'TestClass',
|
24
|
+
'retry_count' => 0,
|
25
|
+
'queue' => 'default',
|
26
|
+
'enqueued_at' => Time.parse('01-01-2001 10:00:00UTC')
|
27
|
+
}}
|
28
|
+
|
29
|
+
before do
|
30
|
+
Appsignal.stub(:is_ignored_exception? => false)
|
31
|
+
Appsignal::Transaction.stub(:current => current_transaction)
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with a performance call" do
|
35
|
+
it "should create an instrumentation with the correct params" do
|
36
|
+
ActiveSupport::Notifications.should_receive(:instrument).with(
|
37
|
+
'perform_job.sidekiq',
|
38
|
+
:class => 'TestClass',
|
39
|
+
:method => 'perform',
|
40
|
+
:attempts => 0,
|
41
|
+
:queue => 'default',
|
42
|
+
:queue_time => 60_000
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
|
48
|
+
Appsignal::Integrations::SidekiqPlugin.new.call(worker, item, queue) do
|
49
|
+
# nothing
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with an erroring call" do
|
56
|
+
let(:error) { VerySpecificError.new('the roof') }
|
57
|
+
it "should add exception to appsignal" do
|
58
|
+
current_transaction.should_receive(:add_exception).with(error)
|
59
|
+
end
|
60
|
+
|
61
|
+
after do
|
62
|
+
begin
|
63
|
+
Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
|
64
|
+
Appsignal::Integrations::SidekiqPlugin.new.call(worker, item, queue) do
|
65
|
+
raise error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
rescue VerySpecificError
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "without sidekiq" do
|
74
|
+
before(:all) { Object.send(:remove_const, :Sidekiq) }
|
75
|
+
|
76
|
+
specify { expect { Sidekiq }.to raise_error(NameError) }
|
77
|
+
specify { expect { load file }.to_not raise_error }
|
78
|
+
end
|
79
|
+
end
|
@@ -112,5 +112,28 @@ describe Appsignal::Transaction::Formatter do
|
|
112
112
|
} }
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
116
|
+
context "with a background request" do
|
117
|
+
let(:transaction) { background_job_transaction }
|
118
|
+
before { transaction.truncate! }
|
119
|
+
|
120
|
+
its(:keys) { should =~ [:request_id, :log_entry, :failed] }
|
121
|
+
its([:request_id]) { should == '1' }
|
122
|
+
its([:log_entry]) { should == {
|
123
|
+
:action => "BackgroundJob#perform",
|
124
|
+
:duration => be_within(0.01).of(100.0),
|
125
|
+
:end => 978364860.1,
|
126
|
+
:queue_duration => 10.0,
|
127
|
+
:priority => 1,
|
128
|
+
:attempts => 0,
|
129
|
+
:queue => 'default',
|
130
|
+
:environment => {},
|
131
|
+
:kind => "background_job",
|
132
|
+
:path => "/foo",
|
133
|
+
:session_data => {},
|
134
|
+
:time => 978364860.0,
|
135
|
+
} }
|
136
|
+
its([:failed]) { should be_false }
|
137
|
+
end
|
115
138
|
end
|
116
139
|
end
|
@@ -44,13 +44,42 @@ describe Appsignal::Transaction do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#set_process_action_event' do
|
47
|
+
before { transaction.set_process_action_event(process_action_event) }
|
47
48
|
let(:process_action_event) { notification_event }
|
48
49
|
|
49
50
|
it 'should add a process action event' do
|
50
|
-
transaction.set_process_action_event(process_action_event)
|
51
|
-
|
52
51
|
transaction.process_action_event.should == process_action_event
|
53
52
|
end
|
53
|
+
|
54
|
+
it "should set the action" do
|
55
|
+
transaction.action.should == 'BlogPostsController#show'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should set the kind" do
|
59
|
+
transaction.kind.should == 'http_request'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "set_perform_job_event" do
|
64
|
+
before { transaction.set_perform_job_event(perform_job_event) }
|
65
|
+
let(:perform_job_event) do
|
66
|
+
notification_event(
|
67
|
+
:name => 'perform_job.delayed_job',
|
68
|
+
:payload => create_background_payload
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should add a process action event' do
|
73
|
+
transaction.process_action_event.should == perform_job_event
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should set the action" do
|
77
|
+
transaction.action.should == 'BackgroundJob#perform'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set the kind" do
|
81
|
+
transaction.kind.should == 'background_job'
|
82
|
+
end
|
54
83
|
end
|
55
84
|
|
56
85
|
describe "#set_tags" do
|
@@ -287,7 +316,26 @@ describe Appsignal::Transaction do
|
|
287
316
|
end
|
288
317
|
end
|
289
318
|
|
290
|
-
#
|
319
|
+
describe "#queue_start" do
|
320
|
+
subject { transaction.queue_start }
|
321
|
+
|
322
|
+
context "for a http request" do
|
323
|
+
let(:transaction) { regular_transaction }
|
324
|
+
|
325
|
+
it "should call http_queue_start" do
|
326
|
+
transaction.should_receive(:http_queue_start)
|
327
|
+
subject
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context "for a background job" do
|
332
|
+
let(:transaction) { background_job_transaction }
|
333
|
+
|
334
|
+
it "should get the queue start from the payload" do
|
335
|
+
subject.should == 978364850.0
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
291
339
|
|
292
340
|
describe "#http_queue_start" do
|
293
341
|
let(:slightly_earlier_time) { fixed_time - 10.0 }
|
@@ -329,6 +377,8 @@ describe Appsignal::Transaction do
|
|
329
377
|
end
|
330
378
|
end
|
331
379
|
|
380
|
+
# protected
|
381
|
+
|
332
382
|
describe '#add_sanitized_context!' do
|
333
383
|
subject { transaction.send(:add_sanitized_context!) }
|
334
384
|
|
data/spec/spec_helper.rb
CHANGED
@@ -24,4 +24,15 @@ module NotificationHelpers
|
|
24
24
|
:db_runtime => 500
|
25
25
|
}.merge(args)
|
26
26
|
end
|
27
|
+
|
28
|
+
def create_background_payload(args={})
|
29
|
+
{
|
30
|
+
:class => 'BackgroundJob',
|
31
|
+
:method => 'perform',
|
32
|
+
:priority => 1,
|
33
|
+
:attempts => 0,
|
34
|
+
:queue => 'default',
|
35
|
+
:queue_start => fixed_time - 10,
|
36
|
+
}
|
37
|
+
end
|
27
38
|
end
|
@@ -59,6 +59,23 @@ module TransactionHelpers
|
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
+
def background_job_transaction(args={})
|
63
|
+
Appsignal::Transaction.create(
|
64
|
+
'1',
|
65
|
+
{
|
66
|
+
'SERVER_NAME' => 'localhost',
|
67
|
+
'action_dispatch.routes' => 'not_available'
|
68
|
+
}.merge(args)
|
69
|
+
).tap do |o|
|
70
|
+
o.set_perform_job_event(
|
71
|
+
notification_event(
|
72
|
+
:name => 'perform_job.delayed_job',
|
73
|
+
:payload => create_background_payload
|
74
|
+
)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
62
79
|
def appsignal_transaction(args={})
|
63
80
|
process_action_event = args.delete(:process_action_event)
|
64
81
|
events = args.delete(:events) || [
|
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: 0.8.0.alpha.0
|
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: 2013-12-
|
15
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - ! '>='
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: timecop
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
115
129
|
description: The official appsignal.com gem
|
116
130
|
email:
|
117
131
|
- support@appsignal.com
|
@@ -135,6 +149,7 @@ files:
|
|
135
149
|
- gemfiles/rails-3.1.gemfile
|
136
150
|
- gemfiles/rails-3.2.gemfile
|
137
151
|
- gemfiles/rails-4.0.gemfile
|
152
|
+
- gemfiles/rails-4.1.gemfile
|
138
153
|
- gemfiles/sinatra.gemfile
|
139
154
|
- lib/appsignal.rb
|
140
155
|
- lib/appsignal/agent.rb
|
@@ -153,6 +168,7 @@ files:
|
|
153
168
|
- lib/appsignal/integrations/capistrano/careful_logger.rb
|
154
169
|
- lib/appsignal/integrations/passenger.rb
|
155
170
|
- lib/appsignal/integrations/rails.rb
|
171
|
+
- lib/appsignal/integrations/sidekiq.rb
|
156
172
|
- lib/appsignal/integrations/sinatra.rb
|
157
173
|
- lib/appsignal/integrations/unicorn.rb
|
158
174
|
- lib/appsignal/marker.rb
|
@@ -180,6 +196,7 @@ files:
|
|
180
196
|
- spec/lib/appsignal/integrations/capistrano_spec.rb
|
181
197
|
- spec/lib/appsignal/integrations/passenger_spec.rb
|
182
198
|
- spec/lib/appsignal/integrations/rails_spec.rb
|
199
|
+
- spec/lib/appsignal/integrations/sidekiq_spec.rb
|
183
200
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
184
201
|
- spec/lib/appsignal/integrations/unicorn_spec.rb
|
185
202
|
- spec/lib/appsignal/marker_spec.rb
|
@@ -217,9 +234,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
234
|
version: 1.9.3
|
218
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
236
|
requirements:
|
220
|
-
- - ! '
|
237
|
+
- - ! '>'
|
221
238
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
239
|
+
version: 1.3.1
|
223
240
|
requirements: []
|
224
241
|
rubyforge_project:
|
225
242
|
rubygems_version: 2.0.3
|
@@ -240,6 +257,7 @@ test_files:
|
|
240
257
|
- spec/lib/appsignal/integrations/capistrano_spec.rb
|
241
258
|
- spec/lib/appsignal/integrations/passenger_spec.rb
|
242
259
|
- spec/lib/appsignal/integrations/rails_spec.rb
|
260
|
+
- spec/lib/appsignal/integrations/sidekiq_spec.rb
|
243
261
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
244
262
|
- spec/lib/appsignal/integrations/unicorn_spec.rb
|
245
263
|
- spec/lib/appsignal/marker_spec.rb
|