appsignal 0.6.7 → 0.7.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +3 -2
- data/.travis.yml +11 -11
- data/CHANGELOG.md +6 -0
- data/README.md +26 -0
- data/Rakefile +32 -3
- data/appsignal.gemspec +25 -16
- data/gemfiles/no_dependencies.gemfile +3 -0
- data/gemfiles/{3.0.gemfile → rails-3.0.gemfile} +2 -1
- data/gemfiles/{3.1.gemfile → rails-3.1.gemfile} +2 -1
- data/gemfiles/{3.2.gemfile → rails-3.2.gemfile} +2 -1
- data/gemfiles/{4.0.gemfile → rails-4.0.gemfile} +2 -1
- data/gemfiles/sinatra.gemfile +5 -0
- data/lib/appsignal.rb +30 -25
- data/lib/appsignal/agent.rb +37 -17
- data/lib/appsignal/aggregator.rb +2 -4
- data/lib/appsignal/aggregator/middleware.rb +4 -0
- data/lib/appsignal/aggregator/middleware/action_view_sanitizer.rb +23 -0
- data/lib/appsignal/aggregator/middleware/active_record_sanitizer.rb +64 -0
- data/lib/appsignal/aggregator/middleware/chain.rb +101 -0
- data/lib/appsignal/aggregator/middleware/delete_blanks.rb +16 -0
- data/lib/appsignal/aggregator/post_processor.rb +21 -18
- data/lib/appsignal/auth_check.rb +7 -21
- data/lib/appsignal/capistrano.rb +1 -36
- data/lib/appsignal/cli.rb +30 -46
- data/lib/appsignal/config.rb +46 -61
- data/lib/appsignal/integrations/capistrano.rb +44 -0
- data/lib/appsignal/{careful_logger.rb → integrations/capistrano/careful_logger.rb} +2 -0
- data/lib/appsignal/integrations/passenger.rb +6 -6
- data/lib/appsignal/integrations/rails.rb +33 -0
- data/lib/appsignal/integrations/sinatra.rb +20 -0
- data/lib/appsignal/marker.rb +9 -10
- data/lib/appsignal/rack/instrumentation.rb +28 -0
- data/lib/appsignal/rack/listener.rb +33 -0
- data/lib/appsignal/transaction.rb +18 -12
- data/lib/appsignal/transaction/formatter.rb +96 -0
- data/lib/appsignal/transaction/params_sanitizer.rb +80 -78
- data/lib/appsignal/transmitter.rb +10 -9
- data/lib/appsignal/version.rb +1 -1
- data/lib/generators/appsignal/appsignal_generator.rb +20 -21
- data/lib/generators/appsignal/templates/appsignal.yml +15 -21
- data/spec/{appsignal → lib/appsignal}/agent_spec.rb +69 -1
- data/spec/lib/appsignal/aggregator/middleware/action_view_sanitizer_spec.rb +32 -0
- data/spec/lib/appsignal/aggregator/middleware/active_record_sanitizer_spec.rb +215 -0
- data/spec/{appsignal → lib/appsignal/aggregator}/middleware/chain_spec.rb +5 -5
- data/spec/{appsignal → lib/appsignal/aggregator}/middleware/delete_blanks_spec.rb +2 -2
- data/spec/{appsignal → lib/appsignal}/aggregator/post_processor_spec.rb +15 -6
- data/spec/{appsignal → lib/appsignal}/aggregator_spec.rb +4 -1
- data/spec/{appsignal → lib/appsignal}/auth_check_spec.rb +8 -23
- data/spec/{appsignal → lib/appsignal}/cli_spec.rb +65 -66
- data/spec/lib/appsignal/config_spec.rb +132 -0
- data/spec/lib/appsignal/integrations/capistrano_spec.rb +123 -0
- data/spec/{appsignal → lib/appsignal}/integrations/passenger_spec.rb +0 -1
- data/spec/lib/appsignal/integrations/rails_spec.rb +38 -0
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +43 -0
- data/spec/{appsignal → lib/appsignal}/marker_spec.rb +20 -23
- data/spec/lib/appsignal/rack/instrumentation_spec.rb +49 -0
- data/spec/{appsignal → lib/appsignal/rack}/listener_spec.rb +39 -6
- data/spec/{appsignal/transaction/transaction_formatter_spec.rb → lib/appsignal/transaction/formatter_spec.rb} +29 -6
- data/spec/{appsignal → lib/appsignal}/transaction/params_sanitizer_spec.rb +13 -12
- data/spec/{appsignal → lib/appsignal}/transaction_spec.rb +52 -7
- data/spec/{appsignal → lib/appsignal}/transmitter_spec.rb +27 -20
- data/spec/lib/appsignal_spec.rb +230 -0
- data/spec/lib/generators/appsignal/appsignal_generator_spec.rb +166 -0
- data/spec/lib/tmp/config/appsignal.yml +2 -0
- data/spec/spec_helper.rb +29 -20
- data/spec/support/delegate_matcher.rb +0 -1
- data/spec/support/fixtures/generated_config.yml +20 -0
- data/{log/.gitkeep → spec/support/fixtures/uploaded_file.txt} +0 -0
- data/spec/support/helpers/config_helpers.rb +24 -0
- data/spec/support/helpers/notification_helpers.rb +0 -2
- data/spec/support/helpers/transaction_helpers.rb +17 -2
- data/spec/support/project_fixture/config/appsignal.yml +18 -0
- data/spec/support/project_fixture/log/.gitkeep +0 -0
- data/spec/support/rails/my_app.rb +6 -0
- metadata +99 -83
- data/config/appsignal.yml +0 -10
- data/lib/appsignal/listener.rb +0 -21
- data/lib/appsignal/middleware.rb +0 -3
- data/lib/appsignal/middleware/action_view_sanitizer.rb +0 -21
- data/lib/appsignal/middleware/active_record_sanitizer.rb +0 -62
- data/lib/appsignal/middleware/chain.rb +0 -99
- data/lib/appsignal/middleware/delete_blanks.rb +0 -12
- data/lib/appsignal/railtie.rb +0 -37
- data/lib/appsignal/to_appsignal_hash.rb +0 -21
- data/lib/appsignal/transaction/transaction_formatter.rb +0 -67
- data/spec/appsignal/capistrano_spec.rb +0 -81
- data/spec/appsignal/config_spec.rb +0 -177
- data/spec/appsignal/inactive_railtie_spec.rb +0 -32
- data/spec/appsignal/middleware/action_view_sanitizer_spec.rb +0 -27
- data/spec/appsignal/middleware/active_record_sanitizer_spec.rb +0 -212
- data/spec/appsignal/railtie_spec.rb +0 -74
- data/spec/appsignal/to_appsignal_hash_spec.rb +0 -29
- data/spec/appsignal_spec.rb +0 -195
- data/spec/generators/appsignal/appsignal_generator_spec.rb +0 -181
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if rails_present?
|
4
|
+
describe Appsignal::Integrations::Railtie do
|
5
|
+
context "after initializing the app" do
|
6
|
+
before :all do
|
7
|
+
MyApp::Application.config.root = project_fixture_path
|
8
|
+
MyApp::Application.initialize!
|
9
|
+
end
|
10
|
+
|
11
|
+
context "logger" do
|
12
|
+
subject { Appsignal.logger }
|
13
|
+
|
14
|
+
it { should be_a Logger }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "config" do
|
18
|
+
subject { Appsignal.config }
|
19
|
+
|
20
|
+
it { should be_a(Appsignal::Config) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "agent" do
|
24
|
+
subject { Appsignal.agent }
|
25
|
+
|
26
|
+
it { should be_a(Appsignal::Agent) }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have added the listener middleware" do
|
30
|
+
MyApp::Application.middleware.to_a.should include Appsignal::Rack::Listener
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not have added the instrumentation middleware" do
|
34
|
+
MyApp::Application.middleware.to_a.should_not include Appsignal::Rack::Instrumentation
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'sinatra'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
if defined?(::Sinatra)
|
9
|
+
ENV['APPSIGNAL_PUSH_API_KEY'] = 'key'
|
10
|
+
require 'appsignal/integrations/sinatra'
|
11
|
+
|
12
|
+
describe "Sinatra integration" do
|
13
|
+
context "logger" do
|
14
|
+
subject { Appsignal.logger }
|
15
|
+
|
16
|
+
it { should be_a Logger }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "config" do
|
20
|
+
subject { Appsignal.config }
|
21
|
+
|
22
|
+
it { should be_a(Appsignal::Config) }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "agent" do
|
26
|
+
subject { Appsignal.agent }
|
27
|
+
|
28
|
+
it { should be_a(Appsignal::Agent) }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have added the listener middleware" do
|
32
|
+
Sinatra::Application.middleware.to_a.should include(
|
33
|
+
[Appsignal::Rack::Listener, [], nil]
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have added the instrumentation middleware" do
|
38
|
+
Sinatra::Application.middleware.to_a.should include(
|
39
|
+
[Appsignal::Rack::Instrumentation, [], nil]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'capistrano'
|
2
3
|
|
3
4
|
describe Appsignal::Marker do
|
5
|
+
let(:config) { project_fixture_config }
|
4
6
|
let(:marker) {
|
5
|
-
Appsignal::Marker.new(
|
7
|
+
Appsignal::Marker.new(
|
8
|
+
{
|
6
9
|
:revision => '503ce0923ed177a3ce000005',
|
7
10
|
:repository => 'master',
|
8
11
|
:user => 'batman',
|
9
|
-
:rails_env => '
|
12
|
+
:rails_env => 'production'
|
10
13
|
},
|
11
|
-
|
12
|
-
'development',
|
14
|
+
config,
|
13
15
|
logger
|
14
16
|
)
|
15
17
|
}
|
@@ -17,23 +19,20 @@ describe Appsignal::Marker do
|
|
17
19
|
let(:logger) { Logger.new(log) }
|
18
20
|
|
19
21
|
context "transmit" do
|
22
|
+
let(:transmitter) { double }
|
20
23
|
before do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
and_return(@transmitter)
|
24
|
+
Appsignal::Transmitter.should_receive(:new).with(
|
25
|
+
'markers', config
|
26
|
+
).and_return(transmitter)
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should transmit data" do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:rails_env => "development"
|
35
|
-
}
|
36
|
-
)
|
30
|
+
transmitter.should_receive(:transmit).with(
|
31
|
+
:revision => '503ce0923ed177a3ce000005',
|
32
|
+
:repository => 'master',
|
33
|
+
:user => 'batman',
|
34
|
+
:rails_env => 'production'
|
35
|
+
)
|
37
36
|
|
38
37
|
marker.transmit
|
39
38
|
end
|
@@ -41,19 +40,17 @@ describe Appsignal::Marker do
|
|
41
40
|
context "logs" do
|
42
41
|
shared_examples_for "logging info and errors" do
|
43
42
|
it "should log status 200" do
|
44
|
-
|
43
|
+
transmitter.should_receive(:transmit).and_return('200')
|
45
44
|
|
46
45
|
marker.transmit
|
47
46
|
|
48
47
|
log.string.should include('Notifying Appsignal of deploy...')
|
49
|
-
log.string.should include(
|
50
|
-
'Appsignal has been notified of this deploy!'
|
51
|
-
)
|
48
|
+
log.string.should include('Appsignal has been notified of this deploy!')
|
52
49
|
end
|
53
50
|
|
54
51
|
it "should log other status" do
|
55
|
-
|
56
|
-
|
52
|
+
transmitter.should_receive(:transmit).and_return('500')
|
53
|
+
transmitter.should_receive(:uri).and_return('http://localhost:3000/1/markers')
|
57
54
|
|
58
55
|
marker.transmit
|
59
56
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Appsignal::Rack::Instrumentation do
|
4
|
+
before :all do
|
5
|
+
start_agent
|
6
|
+
@events = []
|
7
|
+
@subscriber = ActiveSupport::Notifications.subscribe do |*args|
|
8
|
+
@events << ActiveSupport::Notifications::Event.new(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
after :all do
|
12
|
+
ActiveSupport::Notifications.unsubscribe(@subscriber)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:app) { double(:call => true) }
|
16
|
+
let(:env) { {} }
|
17
|
+
let(:middleware) { Appsignal::Rack::Instrumentation.new(app, {}) }
|
18
|
+
|
19
|
+
describe "#call" do
|
20
|
+
it "should instrument the call" do
|
21
|
+
app.should_receive(:call).with(env)
|
22
|
+
middleware.stub(:raw_payload => {})
|
23
|
+
|
24
|
+
middleware.call(env)
|
25
|
+
|
26
|
+
@events.last.name.should == 'process_action.rack'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "raw_payload" do
|
31
|
+
let(:env) do
|
32
|
+
{
|
33
|
+
'rack.input' => StringIO.new,
|
34
|
+
'REQUEST_METHOD' => 'GET',
|
35
|
+
'PATH_INFO' => '/homepage',
|
36
|
+
'REQUEST_METHOD' => 'GET',
|
37
|
+
'QUERY_STRING' => 'param=something'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
subject { middleware.raw_payload(env) }
|
41
|
+
|
42
|
+
it { should == {
|
43
|
+
:action => 'GET:/homepage',
|
44
|
+
:params => {'param' => 'something'},
|
45
|
+
:method => 'GET',
|
46
|
+
:path => '/homepage'
|
47
|
+
} }
|
48
|
+
end
|
49
|
+
end
|
@@ -10,16 +10,23 @@ class AppWithError
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe Appsignal::Listener do
|
13
|
+
describe Appsignal::Rack::Listener do
|
14
|
+
before :all do
|
15
|
+
start_agent
|
16
|
+
end
|
17
|
+
let(:app) { double(:call => true) }
|
18
|
+
let(:middleware) { Appsignal::Rack::Listener.new(app, {})}
|
19
|
+
let(:env) { {} }
|
20
|
+
|
14
21
|
describe '#call' do
|
15
|
-
let(:app) { double(:call => true) }
|
16
|
-
let(:env) { {'action_dispatch.request_id' => '1'} }
|
17
|
-
let(:middleware) { Appsignal::Listener.new(app, {})}
|
18
22
|
let(:current) { double(:complete! => true, :add_exception => true) }
|
19
|
-
before
|
23
|
+
before do
|
24
|
+
middleware.stub(:request_id => '1')
|
25
|
+
Appsignal::Transaction.stub(:current => current)
|
26
|
+
end
|
20
27
|
|
21
28
|
describe 'around call' do
|
22
|
-
it 'should
|
29
|
+
it 'should create an appsignal transaction' do
|
23
30
|
Appsignal::Transaction.should_receive(:create).with('1', env)
|
24
31
|
end
|
25
32
|
|
@@ -27,6 +34,14 @@ describe Appsignal::Listener do
|
|
27
34
|
current.should_receive(:complete!)
|
28
35
|
end
|
29
36
|
|
37
|
+
context "when not active" do
|
38
|
+
before { Appsignal.stub(:active? => false) }
|
39
|
+
|
40
|
+
it 'should not create an appsignal transaction' do
|
41
|
+
Appsignal::Transaction.should_not_receive(:create)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
30
45
|
after { middleware.call(env) }
|
31
46
|
end
|
32
47
|
|
@@ -68,4 +83,22 @@ describe Appsignal::Listener do
|
|
68
83
|
end
|
69
84
|
end
|
70
85
|
end
|
86
|
+
|
87
|
+
describe "#request_id" do
|
88
|
+
subject { middleware.request_id(env) }
|
89
|
+
|
90
|
+
context "when Rails provides a request_id" do
|
91
|
+
let(:env) { {'action_dispatch.request_id' => '1'} }
|
92
|
+
|
93
|
+
it { should == '1' }
|
94
|
+
end
|
95
|
+
|
96
|
+
context "when Rails does not provide a request_id" do
|
97
|
+
before do
|
98
|
+
SecureRandom.stub(:uuid => '2')
|
99
|
+
end
|
100
|
+
|
101
|
+
it { should == '2' }
|
102
|
+
end
|
103
|
+
end
|
71
104
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Appsignal::
|
4
|
-
|
3
|
+
describe Appsignal::Transaction::Formatter do
|
4
|
+
before :all do
|
5
|
+
start_agent
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:klass) { Appsignal::Transaction::Formatter }
|
5
9
|
let(:formatter) { klass.new(transaction) }
|
6
10
|
subject { formatter }
|
7
11
|
before { transaction.stub(:fullpath => '/foo') }
|
@@ -34,6 +38,17 @@ describe Appsignal::TransactionFormatter do
|
|
34
38
|
its([:failed]) { should be_false }
|
35
39
|
end
|
36
40
|
|
41
|
+
context "with a regular request when queue time is present" do
|
42
|
+
let(:transaction) { regular_transaction_with_x_request_start }
|
43
|
+
before { transaction.truncate! }
|
44
|
+
|
45
|
+
context "log_entry content" do
|
46
|
+
subject { formatter.hash[:log_entry] }
|
47
|
+
|
48
|
+
its([:queue_duration]) { should be_within(0.01).of(40.0) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
37
52
|
context "with an exception request" do
|
38
53
|
let(:transaction) { transaction_with_exception }
|
39
54
|
|
@@ -53,10 +68,18 @@ describe Appsignal::TransactionFormatter do
|
|
53
68
|
its(:keys) { should =~ [:exception, :message, :backtrace] }
|
54
69
|
its([:exception]) { should == 'ArgumentError' }
|
55
70
|
its([:message]) { should == 'oh no' }
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
71
|
+
|
72
|
+
if rails_present?
|
73
|
+
its([:backtrace]) { should == [
|
74
|
+
'app/controllers/somethings_controller.rb:10',
|
75
|
+
'/user/local/ruby/path.rb:8'
|
76
|
+
] }
|
77
|
+
else
|
78
|
+
its([:backtrace]) { should == [
|
79
|
+
File.join(project_fixture_path, 'app/controllers/somethings_controller.rb:10'),
|
80
|
+
'/user/local/ruby/path.rb:8'
|
81
|
+
] }
|
82
|
+
end
|
60
83
|
end
|
61
84
|
end
|
62
85
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Appsignal::ParamsSanitizer do
|
4
|
-
let(:
|
3
|
+
describe Appsignal::Transaction::ParamsSanitizer do
|
4
|
+
let(:klass) { Appsignal::Transaction::ParamsSanitizer }
|
5
|
+
let(:file) { uploaded_file }
|
5
6
|
let(:params) do
|
6
7
|
{
|
7
8
|
:text => 'string',
|
@@ -20,17 +21,17 @@ describe Appsignal::ParamsSanitizer do
|
|
20
21
|
}
|
21
22
|
}
|
22
23
|
end
|
23
|
-
let(:sanitized_params) {
|
24
|
-
let(:scrubbed_params) {
|
24
|
+
let(:sanitized_params) { klass.sanitize(params) }
|
25
|
+
let(:scrubbed_params) { klass.scrub(params) }
|
25
26
|
|
26
27
|
describe ".sanitize!" do
|
27
28
|
subject { params }
|
28
|
-
before {
|
29
|
+
before { klass.sanitize!(subject) }
|
29
30
|
|
30
31
|
it { should be_instance_of Hash }
|
31
32
|
its([:text]) { should == 'string' }
|
32
33
|
its([:file]) { should be_instance_of String }
|
33
|
-
its([:file]) { should include '
|
34
|
+
its([:file]) { should include '::UploadedFile' }
|
34
35
|
|
35
36
|
context "hash" do
|
36
37
|
subject { params[:hash] }
|
@@ -45,7 +46,7 @@ describe Appsignal::ParamsSanitizer do
|
|
45
46
|
its([0]) { should == 'something' }
|
46
47
|
its([1]) { should == 'else' }
|
47
48
|
its([2]) { should be_instance_of String }
|
48
|
-
its([2]) { should include '
|
49
|
+
its([2]) { should include '::UploadedFile' }
|
49
50
|
|
50
51
|
context "nested hash" do
|
51
52
|
subject { params[:hash][:nested_array][3] }
|
@@ -53,7 +54,7 @@ describe Appsignal::ParamsSanitizer do
|
|
53
54
|
it { should be_instance_of Hash }
|
54
55
|
its([:key]) { should == 'value' }
|
55
56
|
its([:file]) { should be_instance_of String }
|
56
|
-
its([:file]) { should include '
|
57
|
+
its([:file]) { should include '::UploadedFile' }
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
@@ -65,7 +66,7 @@ describe Appsignal::ParamsSanitizer do
|
|
65
66
|
it { should be_instance_of Hash }
|
66
67
|
its([:text]) { should == 'string' }
|
67
68
|
its([:file]) { should be_instance_of String }
|
68
|
-
its([:file]) { should include '
|
69
|
+
its([:file]) { should include '::UploadedFile' }
|
69
70
|
|
70
71
|
it "does not change the original params" do
|
71
72
|
subject
|
@@ -86,7 +87,7 @@ describe Appsignal::ParamsSanitizer do
|
|
86
87
|
its([0]) { should == 'something' }
|
87
88
|
its([1]) { should == 'else' }
|
88
89
|
its([2]) { should be_instance_of String }
|
89
|
-
its([2]) { should include '
|
90
|
+
its([2]) { should include '::UploadedFile' }
|
90
91
|
|
91
92
|
context "nested hash" do
|
92
93
|
subject { sanitized_params[:hash][:nested_array][3] }
|
@@ -94,7 +95,7 @@ describe Appsignal::ParamsSanitizer do
|
|
94
95
|
it { should be_instance_of Hash }
|
95
96
|
its([:key]) { should == 'value' }
|
96
97
|
its([:file]) { should be_instance_of String }
|
97
|
-
its([:file]) { should include '
|
98
|
+
its([:file]) { should include '::UploadedFile' }
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
@@ -102,7 +103,7 @@ describe Appsignal::ParamsSanitizer do
|
|
102
103
|
|
103
104
|
describe ".scrub!" do
|
104
105
|
subject { params }
|
105
|
-
before {
|
106
|
+
before { klass.scrub!(subject) }
|
106
107
|
|
107
108
|
it { should be_instance_of Hash }
|
108
109
|
its([:text]) { should == '?' }
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Appsignal::Transaction do
|
4
|
+
before :all do
|
5
|
+
start_agent
|
6
|
+
end
|
7
|
+
|
4
8
|
describe '.create' do
|
5
9
|
before { Appsignal::Transaction.create('1', {}) }
|
6
10
|
|
@@ -23,19 +27,20 @@ describe Appsignal::Transaction do
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
let(:
|
28
|
-
|
30
|
+
context "with transaction instance" do
|
31
|
+
let(:env) do
|
32
|
+
{
|
29
33
|
'HTTP_USER_AGENT' => 'IE6',
|
30
34
|
'SERVER_NAME' => 'localhost',
|
31
35
|
'action_dispatch.routes' => 'not_available'
|
32
|
-
}
|
36
|
+
}
|
33
37
|
end
|
38
|
+
let(:transaction) { Appsignal::Transaction.create('1', env) }
|
34
39
|
|
35
40
|
describe '#request' do
|
36
41
|
subject { transaction.request }
|
37
42
|
|
38
|
-
it { should be_a
|
43
|
+
it { should be_a ::Rack::Request }
|
39
44
|
end
|
40
45
|
|
41
46
|
describe '#set_process_action_event' do
|
@@ -284,6 +289,46 @@ describe Appsignal::Transaction do
|
|
284
289
|
|
285
290
|
# protected
|
286
291
|
|
292
|
+
describe "#http_queue_start" do
|
293
|
+
let(:slightly_earlier_time) { fixed_time - 10.0 }
|
294
|
+
let(:slightly_earlier_time_in_msec) { (slightly_earlier_time.to_f * 1_000_000).to_i }
|
295
|
+
subject { transaction.send(:http_queue_start) }
|
296
|
+
|
297
|
+
context "without the env" do
|
298
|
+
let(:env) { nil }
|
299
|
+
|
300
|
+
it { should be_nil }
|
301
|
+
end
|
302
|
+
|
303
|
+
context "with no relevant header set" do
|
304
|
+
it { should be_nil }
|
305
|
+
end
|
306
|
+
|
307
|
+
context "with the HTTP_X_REQUEST_START header set" do
|
308
|
+
let(:env) { {'HTTP_X_REQUEST_START' => "t=#{slightly_earlier_time_in_msec}"} }
|
309
|
+
|
310
|
+
it { should == 978364850.0 }
|
311
|
+
|
312
|
+
context "with unparsable content" do
|
313
|
+
let(:env) { {'HTTP_X_REQUEST_START' => 'something'} }
|
314
|
+
|
315
|
+
it { should be_nil }
|
316
|
+
end
|
317
|
+
|
318
|
+
context "with some cruft" do
|
319
|
+
let(:env) { {'HTTP_X_REQUEST_START' => "t=#{slightly_earlier_time_in_msec}aaaa"} }
|
320
|
+
|
321
|
+
it { should == 978364850.0 }
|
322
|
+
end
|
323
|
+
|
324
|
+
context "with the alternate HTTP_X_QUEUE_START header set" do
|
325
|
+
let(:env) { {'HTTP_X_QUEUE_START' => "t=#{slightly_earlier_time_in_msec}"} }
|
326
|
+
|
327
|
+
it { should == 978364850.0 }
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
287
332
|
describe '#add_sanitized_context!' do
|
288
333
|
subject { transaction.send(:add_sanitized_context!) }
|
289
334
|
|
@@ -351,7 +396,7 @@ describe Appsignal::Transaction do
|
|
351
396
|
end
|
352
397
|
|
353
398
|
it "passes the session data into the params sanitizer" do
|
354
|
-
Appsignal::ParamsSanitizer.should_receive(:sanitize).with({:foo => :bar}).
|
399
|
+
Appsignal::Transaction::ParamsSanitizer.should_receive(:sanitize).with({:foo => :bar}).
|
355
400
|
and_return(:sanitized_foo)
|
356
401
|
subject
|
357
402
|
transaction.sanitized_session_data.should == :sanitized_foo
|
@@ -370,7 +415,7 @@ describe Appsignal::Transaction do
|
|
370
415
|
end
|
371
416
|
|
372
417
|
it "should return an session hash" do
|
373
|
-
Appsignal::ParamsSanitizer.should_receive(:sanitize).with({'foo' => :bar}).
|
418
|
+
Appsignal::Transaction::ParamsSanitizer.should_receive(:sanitize).with({'foo' => :bar}).
|
374
419
|
and_return(:sanitized_foo)
|
375
420
|
subject
|
376
421
|
end
|