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
@@ -4,8 +4,76 @@ class PostProcessingException < Exception
|
|
4
4
|
end
|
5
5
|
|
6
6
|
describe Appsignal::Agent do
|
7
|
+
before :all do
|
8
|
+
start_agent
|
9
|
+
end
|
10
|
+
|
7
11
|
let(:transaction) { regular_transaction }
|
8
12
|
|
13
|
+
describe "#sleep_time" do
|
14
|
+
subject { Appsignal::Agent.new.sleep_time }
|
15
|
+
|
16
|
+
it { should == 60 }
|
17
|
+
|
18
|
+
context "for development" do
|
19
|
+
before do
|
20
|
+
Appsignal.config.stub(:env => 'development')
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should == 10 }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#start_thread" do
|
28
|
+
it "should have started a background thread" do
|
29
|
+
subject.thread.should be_a(Thread)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#subscribe" do
|
34
|
+
it "should have set the appsignal subscriber" do
|
35
|
+
if defined? ActiveSupport::Notifications::Fanout::Subscribers::Timed
|
36
|
+
# ActiveSupport 4
|
37
|
+
subject.subscriber.should be_a ActiveSupport::Notifications::Fanout::Subscribers::Timed
|
38
|
+
else
|
39
|
+
# ActiveSupport 3
|
40
|
+
subject.subscriber.should be_a ActiveSupport::Notifications::Fanout::Subscriber
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "handling events" do
|
45
|
+
before do
|
46
|
+
Appsignal::Transaction.create('123', {})
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should should not listen to events that start with a bang" do
|
50
|
+
Appsignal::Transaction.current.should_not receive(:add_event)
|
51
|
+
|
52
|
+
ActiveSupport::Notifications.instrument '!render_template'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should add a normal event" do
|
56
|
+
Appsignal::Transaction.current.should_not receive(:set_process_action_event)
|
57
|
+
Appsignal::Transaction.current.should receive(:add_event).with(
|
58
|
+
kind_of(ActiveSupport::Notifications::Event)
|
59
|
+
).at_least(:once)
|
60
|
+
|
61
|
+
ActiveSupport::Notifications.instrument 'render_template'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should add and set a process action event" do
|
65
|
+
Appsignal::Transaction.current.should receive(:set_process_action_event).with(
|
66
|
+
kind_of(ActiveSupport::Notifications::Event)
|
67
|
+
).at_least(:once)
|
68
|
+
Appsignal::Transaction.current.should receive(:add_event).with(
|
69
|
+
kind_of(ActiveSupport::Notifications::Event)
|
70
|
+
).at_least(:once)
|
71
|
+
|
72
|
+
ActiveSupport::Notifications.instrument 'process_action.rack'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
9
77
|
describe "#enqueue" do
|
10
78
|
it "forwards to the aggregator" do
|
11
79
|
subject.aggregator.should respond_to(:add)
|
@@ -57,7 +125,7 @@ describe Appsignal::Agent do
|
|
57
125
|
|
58
126
|
describe "#shutdown" do
|
59
127
|
before do
|
60
|
-
ActiveSupport::Notifications.should_receive(:unsubscribe).with(
|
128
|
+
ActiveSupport::Notifications.should_receive(:unsubscribe).with(subject.subscriber)
|
61
129
|
Thread.should_receive(:kill).with(subject.thread)
|
62
130
|
end
|
63
131
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if rails_present?
|
4
|
+
require 'action_view'
|
5
|
+
require 'appsignal/aggregator/middleware/action_view_sanitizer'
|
6
|
+
|
7
|
+
describe Appsignal::Aggregator::Middleware::ActionViewSanitizer do
|
8
|
+
let(:klass) { Appsignal::Aggregator::Middleware::ActionViewSanitizer }
|
9
|
+
let(:sanitizer) { klass.new }
|
10
|
+
|
11
|
+
describe "#call" do
|
12
|
+
before { Rails.root.stub(:to_s => '/var/www/app/20130101') }
|
13
|
+
let(:event) do
|
14
|
+
notification_event(
|
15
|
+
:name => 'render_partial.action_view',
|
16
|
+
:payload => create_payload(payload)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
let(:payload) do
|
20
|
+
{
|
21
|
+
:identifier => '/var/www/app/20130101/app/views/home/index/html.erb'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
subject { event.payload }
|
25
|
+
before { sanitizer.call(event) { } }
|
26
|
+
|
27
|
+
it "should strip Rails root from the path" do
|
28
|
+
payload[:identifier].should == 'app/views/home/index/html.erb'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if rails_present?
|
4
|
+
require 'active_record'
|
5
|
+
require 'appsignal/aggregator/middleware/active_record_sanitizer'
|
6
|
+
|
7
|
+
describe Appsignal::Aggregator::Middleware::ActiveRecordSanitizer do
|
8
|
+
let(:klass) { Appsignal::Aggregator::Middleware::ActiveRecordSanitizer }
|
9
|
+
let(:sql_event_sanitizer) { klass.new }
|
10
|
+
let(:connection_config) { {} }
|
11
|
+
before do
|
12
|
+
if ActiveRecord::Base.respond_to?(:connection_config)
|
13
|
+
# Rails 3.1+
|
14
|
+
ActiveRecord::Base.stub(
|
15
|
+
:connection_config => connection_config
|
16
|
+
)
|
17
|
+
else
|
18
|
+
# Rails 3.0
|
19
|
+
spec = double(:config => connection_config)
|
20
|
+
ActiveRecord::Base.stub(
|
21
|
+
:connection_pool => double(:spec => spec)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#call" do
|
27
|
+
let(:name) { 'Model load' }
|
28
|
+
let(:binds) { [] }
|
29
|
+
let(:event) do
|
30
|
+
notification_event(
|
31
|
+
:name => 'sql.active_record',
|
32
|
+
:payload => create_payload(
|
33
|
+
:name => name,
|
34
|
+
:sql => sql,
|
35
|
+
:binds => binds,
|
36
|
+
:connection_id => 1111
|
37
|
+
)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
subject { event.payload[:sql] }
|
41
|
+
before { sql_event_sanitizer.call(event) { } }
|
42
|
+
|
43
|
+
context "connection id and bindings" do
|
44
|
+
let(:sql) { '' }
|
45
|
+
subject { event.payload }
|
46
|
+
|
47
|
+
it { should_not have_key(:connection_id) }
|
48
|
+
it { should_not have_key(:binds) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with backtick table names" do
|
52
|
+
before { sql_event_sanitizer.stub(:adapter_uses_double_quoted_table_names? => false) }
|
53
|
+
|
54
|
+
context "single quoted data value" do
|
55
|
+
let(:sql) { "SELECT `table`.* FROM `table` WHERE `id` = 'secret'" }
|
56
|
+
|
57
|
+
it { should == "SELECT `table`.* FROM `table` WHERE `id` = ?" }
|
58
|
+
|
59
|
+
context "with an escaped single quote" do
|
60
|
+
let(:sql) { "`id` = '\\'big\\' secret'" }
|
61
|
+
|
62
|
+
it { should == "`id` = ?" }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with an escaped double quote" do
|
66
|
+
let(:sql) { "`id` = '\\\"big\\\" secret'" }
|
67
|
+
|
68
|
+
it { should == "`id` = ?" }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "double quoted data value" do
|
73
|
+
let(:sql) { 'SELECT `table`.* FROM `table` WHERE `id` = "secret"' }
|
74
|
+
|
75
|
+
it { should == 'SELECT `table`.* FROM `table` WHERE `id` = ?' }
|
76
|
+
|
77
|
+
context "with an escaped single quote" do
|
78
|
+
let(:sql) { '`id` = "\\\'big\\\' secret"' }
|
79
|
+
|
80
|
+
it { should == "`id` = ?" }
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with an escaped double quote" do
|
84
|
+
let(:sql) { '`id` = "\\"big\\" secret"' }
|
85
|
+
|
86
|
+
it { should == "`id` = ?" }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "numeric parameter" do
|
91
|
+
let(:sql) { 'SELECT `table`.* FROM `table` WHERE `id` = 1' }
|
92
|
+
|
93
|
+
it { should == 'SELECT `table`.* FROM `table` WHERE `id` = ?' }
|
94
|
+
end
|
95
|
+
|
96
|
+
context "parameter array" do
|
97
|
+
let(:sql) { 'SELECT `table`.* FROM `table` WHERE `id` IN (1, 2)' }
|
98
|
+
|
99
|
+
it { should == 'SELECT `table`.* FROM `table` WHERE `id` IN (?)' }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "with double quote style table names and no prepared statements" do
|
104
|
+
let(:connection_config) { {:adapter => 'postgresql', :prepared_statements => false} }
|
105
|
+
|
106
|
+
context "single quoted data value" do
|
107
|
+
let(:sql) { "SELECT \"table\".* FROM \"table\" WHERE \"id\" = 'secret'" }
|
108
|
+
|
109
|
+
it { should == "SELECT \"table\".* FROM \"table\" WHERE \"id\" = ?" }
|
110
|
+
|
111
|
+
context "with an escaped single quote" do
|
112
|
+
let(:sql) { "\"id\" = '\\'big\\' secret'" }
|
113
|
+
|
114
|
+
it { should == "\"id\" = ?" }
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with an escaped double quote" do
|
118
|
+
let(:sql) { "\"id\" = '\\\"big\\\" secret'" }
|
119
|
+
|
120
|
+
it { should == "\"id\" = ?" }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "numeric parameter" do
|
125
|
+
let(:sql) { 'SELECT "table".* FROM "table" WHERE "id"=1' }
|
126
|
+
|
127
|
+
it { should == 'SELECT "table".* FROM "table" WHERE "id"=?' }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "skip sanitization for prepared statements" do
|
132
|
+
let(:connection_config) { {:adapter => 'postgresql'} }
|
133
|
+
|
134
|
+
let(:sql) { 'SELECT "table".* FROM "table" WHERE "id"=$1' }
|
135
|
+
|
136
|
+
it { should == 'SELECT "table".* FROM "table" WHERE "id"=$1' }
|
137
|
+
end
|
138
|
+
|
139
|
+
context "skip sanitization for schema queries" do
|
140
|
+
let(:name) { 'SCHEMA' }
|
141
|
+
let(:sql) { 'SET client_min_messages TO 22' }
|
142
|
+
|
143
|
+
it { should == 'SET client_min_messages TO 22' }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "#schema_query?" do
|
148
|
+
let(:payload) { {} }
|
149
|
+
let(:event) { notification_event(:payload => payload) }
|
150
|
+
subject { sql_event_sanitizer.schema_query?(event) }
|
151
|
+
|
152
|
+
it { should be_false }
|
153
|
+
|
154
|
+
context "when name is schema" do
|
155
|
+
let(:payload) { {:name => 'SCHEMA'} }
|
156
|
+
|
157
|
+
it { should be_true }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "connection config" do
|
162
|
+
describe "#connection_config" do
|
163
|
+
let(:connection_config) { {:adapter => 'adapter'} }
|
164
|
+
|
165
|
+
subject { sql_event_sanitizer.connection_config }
|
166
|
+
|
167
|
+
it { should == {:adapter => 'adapter'} }
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#adapter_uses_double_quoted_table_names?" do
|
171
|
+
subject { sql_event_sanitizer.adapter_uses_double_quoted_table_names? }
|
172
|
+
|
173
|
+
context "when using mysql" do
|
174
|
+
let(:connection_config) { {:adapter => 'mysql'} }
|
175
|
+
|
176
|
+
it { should be_false }
|
177
|
+
end
|
178
|
+
|
179
|
+
context "when using postgresql" do
|
180
|
+
let(:connection_config) { {:adapter => 'postgresql'} }
|
181
|
+
|
182
|
+
it { should be_true }
|
183
|
+
end
|
184
|
+
|
185
|
+
context "when using sqlite" do
|
186
|
+
let(:connection_config) { {:adapter => 'sqlite'} }
|
187
|
+
|
188
|
+
it { should be_true }
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "adapter_uses_prepared_statements?" do
|
193
|
+
subject { sql_event_sanitizer.adapter_uses_prepared_statements? }
|
194
|
+
|
195
|
+
context "when using mysql" do
|
196
|
+
let(:connection_config) { {:adapter => 'mysql'} }
|
197
|
+
|
198
|
+
it { should be_false }
|
199
|
+
end
|
200
|
+
|
201
|
+
context "when using postgresql" do
|
202
|
+
let(:connection_config) { {:adapter => 'postgresql'} }
|
203
|
+
|
204
|
+
it { should be_true }
|
205
|
+
end
|
206
|
+
|
207
|
+
context "when using postgresql and prepared statements is disabled" do
|
208
|
+
let(:connection_config) { {:adapter => 'postgresql', :prepared_statements => false} }
|
209
|
+
|
210
|
+
it { should be_false }
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Appsignal::Middleware do
|
4
|
-
let(:chain_klass) { Appsignal::Middleware::Chain }
|
5
|
-
let(:entry_klass) { Appsignal::Middleware::Entry }
|
3
|
+
describe Appsignal::Aggregator::Middleware do
|
4
|
+
let(:chain_klass) { Appsignal::Aggregator::Middleware::Chain }
|
5
|
+
let(:entry_klass) { Appsignal::Aggregator::Middleware::Entry }
|
6
6
|
let(:chain) { chain_klass.new }
|
7
7
|
let(:entry) { entry_klass.new(object, {:foo => :bar}) }
|
8
8
|
|
9
|
-
describe Appsignal::Middleware::Chain do
|
9
|
+
describe Appsignal::Aggregator::Middleware::Chain do
|
10
10
|
let(:object) { double(:object) }
|
11
11
|
let(:other_object) { double(:other_object) }
|
12
12
|
|
@@ -153,7 +153,7 @@ describe Appsignal::Middleware do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
describe Appsignal::Middleware::Entry do
|
156
|
+
describe Appsignal::Aggregator::Middleware::Entry do
|
157
157
|
|
158
158
|
describe "#make_new" do
|
159
159
|
let(:object) { double }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Appsignal::Middleware::DeleteBlanks do
|
4
|
-
let(:klass) { Appsignal::Middleware::DeleteBlanks }
|
3
|
+
describe Appsignal::Aggregator::Middleware::DeleteBlanks do
|
4
|
+
let(:klass) { Appsignal::Aggregator::Middleware::DeleteBlanks }
|
5
5
|
let(:delete_blanks) { klass.new }
|
6
6
|
|
7
7
|
describe "#call" do
|
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Appsignal::PostProcessor do
|
4
|
-
|
3
|
+
describe Appsignal::Aggregator::PostProcessor do
|
4
|
+
before :all do
|
5
|
+
start_agent
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:klass) { Appsignal::Aggregator::PostProcessor }
|
5
9
|
let(:post_processor) { klass.new(transactions) }
|
6
10
|
|
7
11
|
describe "#initialize" do
|
@@ -73,12 +77,17 @@ describe Appsignal::PostProcessor do
|
|
73
77
|
describe ".default_middleware" do
|
74
78
|
subject { klass.default_middleware }
|
75
79
|
|
76
|
-
it { should be_instance_of Appsignal::Middleware::Chain }
|
80
|
+
it { should be_instance_of Appsignal::Aggregator::Middleware::Chain }
|
77
81
|
|
78
82
|
it "should include the default middleware stack" do
|
79
|
-
subject.exists?(Appsignal::Middleware::DeleteBlanks).should be_true
|
80
|
-
|
81
|
-
|
83
|
+
subject.exists?(Appsignal::Aggregator::Middleware::DeleteBlanks).should be_true
|
84
|
+
if rails_present?
|
85
|
+
subject.exists?(Appsignal::Aggregator::Middleware::ActionViewSanitizer).should be_true
|
86
|
+
subject.exists?(Appsignal::Aggregator::Middleware::ActiveRecordSanitizer).should be_true
|
87
|
+
else
|
88
|
+
subject.exists?(Appsignal::Aggregator::Middleware::ActionViewSanitizer).should be_false
|
89
|
+
subject.exists?(Appsignal::Aggregator::Middleware::ActiveRecordSanitizer).should be_false
|
90
|
+
end
|
82
91
|
end
|
83
92
|
end
|
84
93
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Appsignal::Aggregator do
|
4
|
+
before :all do
|
5
|
+
start_agent
|
6
|
+
end
|
7
|
+
|
4
8
|
let(:aggregator) { Appsignal::Aggregator.new }
|
5
9
|
|
6
10
|
describe "#add" do
|
@@ -178,5 +182,4 @@ describe Appsignal::Aggregator do
|
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
181
|
-
|
182
185
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Appsignal::AuthCheck do
|
4
|
-
let(:
|
4
|
+
let(:config) { project_fixture_config }
|
5
|
+
let(:logger) { Logger.new(StringIO.new) }
|
6
|
+
let(:auth_check) { Appsignal::AuthCheck.new(config, logger) }
|
5
7
|
|
6
8
|
describe "#perform_with_result" do
|
7
9
|
it "should give success message" do
|
@@ -16,7 +18,7 @@ describe Appsignal::AuthCheck do
|
|
16
18
|
['401', 'API key not valid with AppSignal...']
|
17
19
|
end
|
18
20
|
|
19
|
-
it "should give error message" do
|
21
|
+
it "should give an error message" do
|
20
22
|
auth_check.should_receive(:perform).and_return('402')
|
21
23
|
auth_check.perform_with_result.should ==
|
22
24
|
['402', 'Could not confirm authorization: 402']
|
@@ -26,9 +28,10 @@ describe Appsignal::AuthCheck do
|
|
26
28
|
context "transmitting" do
|
27
29
|
before do
|
28
30
|
@transmitter = double
|
29
|
-
Appsignal::Transmitter.should_receive(:new).
|
30
|
-
|
31
|
-
|
31
|
+
Appsignal::Transmitter.should_receive(:new).with(
|
32
|
+
'auth',
|
33
|
+
kind_of(Appsignal::Config)
|
34
|
+
).and_return(@transmitter)
|
32
35
|
end
|
33
36
|
|
34
37
|
describe "#perform" do
|
@@ -37,23 +40,5 @@ describe Appsignal::AuthCheck do
|
|
37
40
|
auth_check.perform
|
38
41
|
end
|
39
42
|
end
|
40
|
-
|
41
|
-
describe "#uri" do
|
42
|
-
before do
|
43
|
-
@transmitter.should_receive(:transmit)
|
44
|
-
auth_check.perform
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should delegate to transmitter" do
|
48
|
-
@transmitter.should_receive(:uri)
|
49
|
-
auth_check.uri
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return uri" do
|
53
|
-
@transmitter.should_receive(:uri).
|
54
|
-
and_return('http://appsignal.com/1/auth')
|
55
|
-
auth_check.uri.should == 'http://appsignal.com/1/auth'
|
56
|
-
end
|
57
|
-
end
|
58
43
|
end
|
59
44
|
end
|