appsignal 1.2.5 → 1.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/circle.yml +4 -0
- data/ext/agent.yml +11 -11
- data/ext/appsignal_extension.c +105 -40
- data/lib/appsignal.rb +18 -6
- data/lib/appsignal/cli/install.rb +3 -3
- data/lib/appsignal/config.rb +19 -5
- data/lib/appsignal/event_formatter.rb +3 -2
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +13 -6
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +0 -1
- data/lib/appsignal/hooks/net_http.rb +2 -5
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/sequel.rb +8 -4
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/integrations/object.rb +35 -0
- data/lib/appsignal/integrations/resque.rb +5 -0
- data/lib/appsignal/integrations/sinatra.rb +2 -2
- data/lib/appsignal/minutely.rb +41 -0
- data/lib/appsignal/params_sanitizer.rb +4 -105
- data/lib/appsignal/rack/sinatra_instrumentation.rb +25 -2
- data/lib/appsignal/transaction.rb +41 -15
- data/lib/appsignal/transmitter.rb +1 -1
- data/lib/appsignal/utils.rb +42 -47
- data/lib/appsignal/utils/params_sanitizer.rb +58 -0
- data/lib/appsignal/utils/query_params_sanitizer.rb +54 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +12 -2
- data/spec/lib/appsignal/extension_spec.rb +4 -0
- data/spec/lib/appsignal/hooks/net_http_spec.rb +20 -28
- data/spec/lib/appsignal/hooks/redis_spec.rb +9 -11
- data/spec/lib/appsignal/integrations/object_spec.rb +211 -0
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
- data/spec/lib/appsignal/minutely_spec.rb +54 -0
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +50 -10
- data/spec/lib/appsignal/subscriber_spec.rb +5 -6
- data/spec/lib/appsignal/transaction_spec.rb +102 -23
- data/spec/lib/appsignal/transmitter_spec.rb +1 -1
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +122 -0
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +194 -0
- data/spec/lib/appsignal/utils_spec.rb +13 -76
- data/spec/lib/appsignal_spec.rb +82 -13
- metadata +15 -11
- data/lib/appsignal/event_formatter/net_http/request_formatter.rb +0 -13
- data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +0 -13
- data/spec/lib/appsignal/event_formatter/net_http/request_formatter_spec.rb +0 -26
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -22
- data/spec/lib/appsignal/params_sanitizer_spec.rb +0 -200
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Appsignal::Hooks::RedisHook do
|
4
4
|
before :all do
|
5
|
-
|
5
|
+
start_agent
|
6
6
|
end
|
7
7
|
|
8
8
|
context "with redis" do
|
@@ -19,27 +19,25 @@ describe Appsignal::Hooks::RedisHook do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
context "and redis instrumentation enabled" do
|
22
|
-
let(:events) { [] }
|
23
22
|
before :all do
|
24
23
|
Appsignal.config.config_hash[:instrument_redis] = true
|
25
24
|
Appsignal::Hooks::RedisHook.new.install
|
26
25
|
end
|
27
|
-
before do
|
28
|
-
ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
|
29
|
-
events << ActiveSupport::Notifications::Event.new(*args)
|
30
|
-
end
|
31
|
-
end
|
32
26
|
after(:all) { Object.send(:remove_const, :Redis) }
|
33
27
|
|
34
28
|
its(:dependencies_present?) { should be_true }
|
35
29
|
|
36
|
-
it "should
|
30
|
+
it "should instrument a redis call" do
|
31
|
+
Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
|
32
|
+
expect( Appsignal::Transaction.current ).to receive(:start_event)
|
33
|
+
.at_least(:once)
|
34
|
+
expect( Appsignal::Transaction.current ).to receive(:finish_event)
|
35
|
+
.at_least(:once)
|
36
|
+
.with('query.redis', nil, nil, 0)
|
37
|
+
|
37
38
|
client = Redis::Client.new
|
38
39
|
|
39
40
|
client.process([]).should == 1
|
40
|
-
|
41
|
-
event = events.last
|
42
|
-
event.name.should == 'query.redis'
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'appsignal/integrations/object'
|
3
|
+
|
4
|
+
describe Object do
|
5
|
+
describe "#instrument_method" do
|
6
|
+
context "with instance method" do
|
7
|
+
let(:klass) do
|
8
|
+
Class.new do
|
9
|
+
def foo
|
10
|
+
1
|
11
|
+
end
|
12
|
+
appsignal_instrument_method :foo
|
13
|
+
end
|
14
|
+
end
|
15
|
+
let(:instance) { klass.new }
|
16
|
+
|
17
|
+
context "when active" do
|
18
|
+
let(:transaction) { regular_transaction }
|
19
|
+
before { Appsignal.config = project_fixture_config }
|
20
|
+
after { Appsignal.config = nil }
|
21
|
+
|
22
|
+
context "with anonymous class" do
|
23
|
+
it "instruments the method and calls it" do
|
24
|
+
expect(Appsignal.active?).to be_true
|
25
|
+
transaction.should_receive(:start_event)
|
26
|
+
transaction.should_receive(:finish_event).with \
|
27
|
+
"foo.AnonymousClass.other", nil, nil, 0
|
28
|
+
expect(instance.foo).to eq(1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with named class" do
|
33
|
+
before do
|
34
|
+
class NamedClass
|
35
|
+
def foo
|
36
|
+
1
|
37
|
+
end
|
38
|
+
appsignal_instrument_method :foo
|
39
|
+
end
|
40
|
+
end
|
41
|
+
after { Object.send(:remove_const, :NamedClass) }
|
42
|
+
let(:klass) { NamedClass }
|
43
|
+
|
44
|
+
it "instruments the method and calls it" do
|
45
|
+
expect(Appsignal.active?).to be_true
|
46
|
+
transaction.should_receive(:start_event)
|
47
|
+
transaction.should_receive(:finish_event).with \
|
48
|
+
"foo.NamedClass.other", nil, nil, 0
|
49
|
+
expect(instance.foo).to eq(1)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with nested named class" do
|
54
|
+
before do
|
55
|
+
module MyModule
|
56
|
+
module NestedModule
|
57
|
+
class NamedClass
|
58
|
+
def bar
|
59
|
+
2
|
60
|
+
end
|
61
|
+
appsignal_instrument_method :bar
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
after { Object.send(:remove_const, :MyModule) }
|
67
|
+
let(:klass) { MyModule::NestedModule::NamedClass }
|
68
|
+
|
69
|
+
it "instruments the method and calls it" do
|
70
|
+
expect(Appsignal.active?).to be_true
|
71
|
+
transaction.should_receive(:start_event)
|
72
|
+
transaction.should_receive(:finish_event).with \
|
73
|
+
"bar.NamedClass.NestedModule.MyModule.other", nil, nil, 0
|
74
|
+
expect(instance.bar).to eq(2)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with custom name" do
|
79
|
+
let(:klass) do
|
80
|
+
Class.new do
|
81
|
+
def foo
|
82
|
+
1
|
83
|
+
end
|
84
|
+
appsignal_instrument_method :foo, name: "my_method.group"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "instruments with custom name" do
|
89
|
+
expect(Appsignal.active?).to be_true
|
90
|
+
transaction.should_receive(:start_event)
|
91
|
+
transaction.should_receive(:finish_event).with \
|
92
|
+
"my_method.group", nil, nil, 0
|
93
|
+
expect(instance.foo).to eq(1)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when not active" do
|
99
|
+
let(:transaction) { Appsignal::Transaction.current }
|
100
|
+
|
101
|
+
it "should not instrument, but still call the method" do
|
102
|
+
expect(Appsignal.active?).to be_false
|
103
|
+
expect(transaction).to_not receive(:start_event)
|
104
|
+
expect(instance.foo).to eq(1)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "with class method" do
|
110
|
+
let(:klass) do
|
111
|
+
Class.new do
|
112
|
+
def self.bar
|
113
|
+
2
|
114
|
+
end
|
115
|
+
appsignal_instrument_class_method :bar
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when active" do
|
120
|
+
let(:transaction) { regular_transaction }
|
121
|
+
before { Appsignal.config = project_fixture_config }
|
122
|
+
after { Appsignal.config = nil }
|
123
|
+
|
124
|
+
context "with anonymous class" do
|
125
|
+
it "instruments the method and calls it" do
|
126
|
+
expect(Appsignal.active?).to be_true
|
127
|
+
transaction.should_receive(:start_event)
|
128
|
+
transaction.should_receive(:finish_event).with \
|
129
|
+
"bar.class_method.AnonymousClass.other", nil, nil, 0
|
130
|
+
expect(klass.bar).to eq(2)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "with named class" do
|
135
|
+
before do
|
136
|
+
class NamedClass
|
137
|
+
def self.bar
|
138
|
+
2
|
139
|
+
end
|
140
|
+
appsignal_instrument_class_method :bar
|
141
|
+
end
|
142
|
+
end
|
143
|
+
after { Object.send(:remove_const, :NamedClass) }
|
144
|
+
let(:klass) { NamedClass }
|
145
|
+
|
146
|
+
it "instruments the method and calls it" do
|
147
|
+
expect(Appsignal.active?).to be_true
|
148
|
+
transaction.should_receive(:start_event)
|
149
|
+
transaction.should_receive(:finish_event).with \
|
150
|
+
"bar.class_method.NamedClass.other", nil, nil, 0
|
151
|
+
expect(klass.bar).to eq(2)
|
152
|
+
end
|
153
|
+
|
154
|
+
context "with nested named class" do
|
155
|
+
before do
|
156
|
+
module MyModule
|
157
|
+
module NestedModule
|
158
|
+
class NamedClass
|
159
|
+
def self.bar
|
160
|
+
2
|
161
|
+
end
|
162
|
+
appsignal_instrument_class_method :bar
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
after { Object.send(:remove_const, :MyModule) }
|
168
|
+
let(:klass) { MyModule::NestedModule::NamedClass }
|
169
|
+
|
170
|
+
it "instruments the method and calls it" do
|
171
|
+
expect(Appsignal.active?).to be_true
|
172
|
+
transaction.should_receive(:start_event)
|
173
|
+
transaction.should_receive(:finish_event).with \
|
174
|
+
"bar.class_method.NamedClass.NestedModule.MyModule.other", nil, nil, 0
|
175
|
+
expect(klass.bar).to eq(2)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
context "with custom name" do
|
181
|
+
let(:klass) do
|
182
|
+
Class.new do
|
183
|
+
def self.bar
|
184
|
+
2
|
185
|
+
end
|
186
|
+
appsignal_instrument_class_method :bar, name: "my_method.group"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it "instruments with custom name" do
|
191
|
+
expect(Appsignal.active?).to be_true
|
192
|
+
transaction.should_receive(:start_event)
|
193
|
+
transaction.should_receive(:finish_event).with \
|
194
|
+
"my_method.group", nil, nil, 0
|
195
|
+
expect(klass.bar).to eq(2)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context "when not active" do
|
201
|
+
let(:transaction) { Appsignal::Transaction.current }
|
202
|
+
|
203
|
+
it "should not instrument, but still call the method" do
|
204
|
+
expect(Appsignal.active?).to be_false
|
205
|
+
expect(transaction).to_not receive(:start_event)
|
206
|
+
expect(klass.bar).to eq(2)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -12,8 +12,8 @@ if sinatra_present? && !padrino_present?
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should have added the instrumentation middleware" do
|
15
|
-
Sinatra::
|
16
|
-
[Appsignal::Rack::
|
15
|
+
Sinatra::Base.middleware.to_a.should include(
|
16
|
+
[Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
|
17
17
|
)
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Appsignal::Minutely do
|
4
|
+
before do
|
5
|
+
Appsignal::Minutely.probes.clear
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a list of probes" do
|
9
|
+
expect( Appsignal::Minutely.probes ).to be_instance_of(Array)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".start" do
|
13
|
+
it "should call the probes periodically" do
|
14
|
+
probe = double
|
15
|
+
expect( probe ).to receive(:call).at_least(:twice)
|
16
|
+
Appsignal::Minutely.probes << probe
|
17
|
+
Appsignal::Minutely.stub(:wait_time => 0.1)
|
18
|
+
|
19
|
+
Appsignal::Minutely.start
|
20
|
+
|
21
|
+
sleep 0.5
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".wait_time" do
|
26
|
+
it "should get the time to the next minute" do
|
27
|
+
Time.any_instance.stub(:sec => 30)
|
28
|
+
expect( Appsignal::Minutely.wait_time ).to eq 30
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".add_gc_probe" do
|
33
|
+
it "should add the gc probe to the list" do
|
34
|
+
expect( Appsignal::Minutely.probes ).to be_empty
|
35
|
+
|
36
|
+
Appsignal::Minutely.add_gc_probe
|
37
|
+
|
38
|
+
expect( Appsignal::Minutely.probes ).to have(1).item
|
39
|
+
expect( Appsignal::Minutely.probes[0] ).to be_instance_of(Appsignal::Minutely::GCProbe)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe Appsignal::Minutely::GCProbe do
|
44
|
+
describe "#call" do
|
45
|
+
it "should collect GC metrics" do
|
46
|
+
expect(Appsignal).to receive(:set_process_gauge).with('gc.count', kind_of(Integer)).once
|
47
|
+
expect(Appsignal).to receive(:set_process_gauge).with('gc.heap_allocated_pages', kind_of(Integer)).once
|
48
|
+
expect(Appsignal).to receive(:set_process_gauge).at_least(10).times
|
49
|
+
|
50
|
+
Appsignal::Minutely::GCProbe.new.call
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -8,6 +8,35 @@ end
|
|
8
8
|
|
9
9
|
if defined?(::Sinatra)
|
10
10
|
describe Appsignal::Rack::SinatraInstrumentation do
|
11
|
+
let(:settings) { double(:raise_errors => false) }
|
12
|
+
let(:app) { double(:call => true, :settings => settings) }
|
13
|
+
let(:env) { {'sinatra.route' => 'GET /', :path => '/', :method => 'GET'} }
|
14
|
+
let(:middleware) { Appsignal::Rack::SinatraInstrumentation.new(app) }
|
15
|
+
|
16
|
+
describe "#call" do
|
17
|
+
before do
|
18
|
+
start_agent
|
19
|
+
middleware.stub(:raw_payload => {})
|
20
|
+
Appsignal.stub(:active? => true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should call without monitoring" do
|
24
|
+
expect(Appsignal::Transaction).to_not receive(:create)
|
25
|
+
end
|
26
|
+
|
27
|
+
after { middleware.call(env) }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".settings" do
|
31
|
+
subject { middleware.settings }
|
32
|
+
|
33
|
+
it "should return the app's settings" do
|
34
|
+
expect(subject).to eq(app.settings)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Appsignal::Rack::SinatraBaseInstrumentation do
|
11
40
|
before :all do
|
12
41
|
start_agent
|
13
42
|
end
|
@@ -16,7 +45,7 @@ if defined?(::Sinatra)
|
|
16
45
|
let(:app) { double(:call => true, :settings => settings) }
|
17
46
|
let(:env) { {'sinatra.route' => 'GET /', :path => '/', :method => 'GET'} }
|
18
47
|
let(:options) { {} }
|
19
|
-
let(:middleware) { Appsignal::Rack::
|
48
|
+
let(:middleware) { Appsignal::Rack::SinatraBaseInstrumentation.new(app, options) }
|
20
49
|
|
21
50
|
describe "#call" do
|
22
51
|
before do
|
@@ -99,8 +128,26 @@ if defined?(::Sinatra)
|
|
99
128
|
end
|
100
129
|
end
|
101
130
|
|
102
|
-
|
103
|
-
|
131
|
+
describe "action name" do
|
132
|
+
it "should set the action" do
|
133
|
+
Appsignal::Transaction.any_instance.should_receive(:set_action).with('GET /')
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with option to set path a mounted_at prefix" do
|
137
|
+
let(:options) {{ :mounted_at => "/api/v2" }}
|
138
|
+
|
139
|
+
it "should call set_action with a prefix path" do
|
140
|
+
Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/v2/")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context "with mounted modular application" do
|
145
|
+
before { env['SCRIPT_NAME'] = '/api' }
|
146
|
+
|
147
|
+
it "should call set_action with an application prefix path" do
|
148
|
+
Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/")
|
149
|
+
end
|
150
|
+
end
|
104
151
|
end
|
105
152
|
|
106
153
|
it "should set metadata" do
|
@@ -123,13 +170,6 @@ if defined?(::Sinatra)
|
|
123
170
|
end
|
124
171
|
end
|
125
172
|
|
126
|
-
context "with option to set path prefix" do
|
127
|
-
let(:options) {{ :mounted_at => "/api/v2" }}
|
128
|
-
it "should call set_action with a prefix path" do
|
129
|
-
Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/v2/")
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
173
|
after { middleware.call(env) rescue VerySpecificError }
|
134
174
|
end
|
135
175
|
end
|
@@ -116,17 +116,16 @@ describe Appsignal::Subscriber do
|
|
116
116
|
it "should call finish with title and body if there is a formatter" do
|
117
117
|
transaction.should_receive(:start_event).once
|
118
118
|
transaction.should_receive(:finish_event).with(
|
119
|
-
'request.
|
119
|
+
'request.faraday',
|
120
|
+
'GET http://www.google.com',
|
120
121
|
'GET http://www.google.com',
|
121
|
-
nil,
|
122
122
|
nil
|
123
123
|
).once
|
124
124
|
|
125
125
|
ActiveSupport::Notifications.instrument(
|
126
|
-
'request.
|
127
|
-
:
|
128
|
-
:
|
129
|
-
:method => 'GET'
|
126
|
+
'request.faraday',
|
127
|
+
:method => 'get',
|
128
|
+
:url => URI('http://www.google.com')
|
130
129
|
)
|
131
130
|
end
|
132
131
|
|
@@ -24,7 +24,6 @@ describe Appsignal::Transaction do
|
|
24
24
|
|
25
25
|
context "class methods" do
|
26
26
|
describe ".create" do
|
27
|
-
|
28
27
|
it "should add the transaction to thread local" do
|
29
28
|
Appsignal::Extension.should_receive(:start_transaction).with('1', 'http_request')
|
30
29
|
|
@@ -447,7 +446,7 @@ describe Appsignal::Transaction do
|
|
447
446
|
end
|
448
447
|
end
|
449
448
|
|
450
|
-
describe "finish_event" do
|
449
|
+
describe "#finish_event" do
|
451
450
|
it "should finish the event in the extension" do
|
452
451
|
transaction.ext.should_receive(:finish_event).with(
|
453
452
|
'name',
|
@@ -481,6 +480,63 @@ describe Appsignal::Transaction do
|
|
481
480
|
end
|
482
481
|
end
|
483
482
|
|
483
|
+
describe "#record_event" do
|
484
|
+
it "should record the event in the extension" do
|
485
|
+
transaction.ext.should_receive(:record_event).with(
|
486
|
+
'name',
|
487
|
+
'title',
|
488
|
+
'body',
|
489
|
+
1000,
|
490
|
+
1
|
491
|
+
)
|
492
|
+
|
493
|
+
transaction.record_event(
|
494
|
+
'name',
|
495
|
+
'title',
|
496
|
+
'body',
|
497
|
+
1000,
|
498
|
+
1
|
499
|
+
)
|
500
|
+
end
|
501
|
+
|
502
|
+
it "should finish the event in the extension with nil arguments" do
|
503
|
+
transaction.ext.should_receive(:record_event).with(
|
504
|
+
'name',
|
505
|
+
'',
|
506
|
+
'',
|
507
|
+
1000,
|
508
|
+
0
|
509
|
+
)
|
510
|
+
|
511
|
+
transaction.record_event(
|
512
|
+
'name',
|
513
|
+
nil,
|
514
|
+
nil,
|
515
|
+
1000,
|
516
|
+
nil
|
517
|
+
)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
|
521
|
+
describe "#instrument" do
|
522
|
+
it "should start and finish an event around the given block" do
|
523
|
+
stub = double
|
524
|
+
stub.should_receive(:method_call).and_return('return value')
|
525
|
+
|
526
|
+
transaction.should_receive(:start_event)
|
527
|
+
transaction.should_receive(:finish_event).with(
|
528
|
+
'name',
|
529
|
+
'title',
|
530
|
+
'body',
|
531
|
+
0
|
532
|
+
)
|
533
|
+
|
534
|
+
transaction.instrument 'name', 'title', 'body' do
|
535
|
+
stub.method_call
|
536
|
+
end.should eq 'return value'
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
484
540
|
context "generic request" do
|
485
541
|
let(:env) { {} }
|
486
542
|
subject { Appsignal::Transaction::GenericRequest.new(env) }
|
@@ -595,38 +651,61 @@ describe Appsignal::Transaction do
|
|
595
651
|
it { should be_nil }
|
596
652
|
end
|
597
653
|
|
598
|
-
context "when not
|
599
|
-
|
600
|
-
after { Appsignal.config.config_hash[:send_params] = true }
|
654
|
+
context "when params method does not exist" do
|
655
|
+
let(:options) { {:params_method => :nonsense} }
|
601
656
|
|
602
657
|
it { should be_nil }
|
603
658
|
end
|
604
659
|
|
605
|
-
context "when
|
606
|
-
|
660
|
+
context "when not sending params" do
|
661
|
+
before { Appsignal.config.config_hash[:send_params] = false }
|
662
|
+
after { Appsignal.config.config_hash[:send_params] = true }
|
607
663
|
|
608
664
|
it { should be_nil }
|
609
665
|
end
|
610
666
|
|
611
667
|
context "with an array" do
|
612
|
-
let(:request)
|
668
|
+
let(:request) do
|
669
|
+
Appsignal::Transaction::GenericRequest.new(background_env_with_data(:params => ['arg1', 'arg2']))
|
670
|
+
end
|
613
671
|
|
614
672
|
it { should == ['arg1', 'arg2'] }
|
673
|
+
|
674
|
+
context "with AppSignal filtering" do
|
675
|
+
before { Appsignal.config.config_hash[:filter_parameters] = %w(foo) }
|
676
|
+
after { Appsignal.config.config_hash[:filter_parameters] = [] }
|
677
|
+
|
678
|
+
it { should == ['arg1', 'arg2'] }
|
679
|
+
end
|
615
680
|
end
|
616
681
|
|
617
682
|
context "with env" do
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
683
|
+
context "with sanitization" do
|
684
|
+
let(:request) do
|
685
|
+
Appsignal::Transaction::GenericRequest.new \
|
686
|
+
http_request_env_with_data(:params => { :foo => :bar })
|
687
|
+
end
|
688
|
+
|
689
|
+
it "should call the params sanitizer" do
|
690
|
+
puts Appsignal.config.config_hash[:filter_parameters].inspect
|
691
|
+
subject.should == { :foo => :bar }
|
692
|
+
end
|
693
|
+
end
|
694
|
+
|
695
|
+
context "with AppSignal filtering" do
|
696
|
+
let(:request) do
|
697
|
+
Appsignal::Transaction::GenericRequest.new \
|
698
|
+
http_request_env_with_data(:params => { :foo => :bar, :baz => :bat })
|
699
|
+
end
|
700
|
+
before { Appsignal.config.config_hash[:filter_parameters] = %w(foo) }
|
701
|
+
after { Appsignal.config.config_hash[:filter_parameters] = [] }
|
702
|
+
|
703
|
+
it "should call the params sanitizer with filtering" do
|
704
|
+
subject.should == {
|
705
|
+
:foo => '[FILTERED]',
|
706
|
+
:baz => :bat
|
707
|
+
}
|
708
|
+
end
|
630
709
|
end
|
631
710
|
end
|
632
711
|
end
|
@@ -684,7 +763,7 @@ describe Appsignal::Transaction do
|
|
684
763
|
end
|
685
764
|
|
686
765
|
it "passes the session data into the params sanitizer" do
|
687
|
-
Appsignal::ParamsSanitizer.should_receive(:sanitize).with({:foo => :bar}).
|
766
|
+
Appsignal::Utils::ParamsSanitizer.should_receive(:sanitize).with({:foo => :bar}).
|
688
767
|
and_return(:sanitized_foo)
|
689
768
|
subject.should == :sanitized_foo
|
690
769
|
end
|
@@ -698,7 +777,7 @@ describe Appsignal::Transaction do
|
|
698
777
|
end
|
699
778
|
|
700
779
|
it "should return an session hash" do
|
701
|
-
Appsignal::ParamsSanitizer.should_receive(:sanitize).with({'foo' => :bar}).
|
780
|
+
Appsignal::Utils::ParamsSanitizer.should_receive(:sanitize).with({'foo' => :bar}).
|
702
781
|
and_return(:sanitized_foo)
|
703
782
|
subject
|
704
783
|
end
|
@@ -719,7 +798,7 @@ describe Appsignal::Transaction do
|
|
719
798
|
end
|
720
799
|
|
721
800
|
it "does not pass the session data into the params sanitizer" do
|
722
|
-
Appsignal::ParamsSanitizer.should_not_receive(:sanitize)
|
801
|
+
Appsignal::Utils::ParamsSanitizer.should_not_receive(:sanitize)
|
723
802
|
subject.should be_nil
|
724
803
|
end
|
725
804
|
end
|