appsignal 2.5.3-java → 2.6.0.beta.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +8 -1
- data/CHANGELOG.md +12 -0
- data/appsignal.gemspec +2 -2
- data/benchmark.rake +6 -0
- data/ext/agent.yml +35 -35
- data/ext/appsignal_extension.c +27 -9
- data/lib/appsignal.rb +15 -19
- data/lib/appsignal/auth_check.rb +2 -0
- data/lib/appsignal/capistrano.rb +2 -0
- data/lib/appsignal/cli.rb +2 -0
- data/lib/appsignal/cli/demo.rb +2 -0
- data/lib/appsignal/cli/diagnose.rb +2 -0
- data/lib/appsignal/cli/helpers.rb +2 -0
- data/lib/appsignal/cli/install.rb +15 -1
- data/lib/appsignal/cli/notify_of_deploy.rb +8 -0
- data/lib/appsignal/config.rb +44 -5
- data/lib/appsignal/demo.rb +2 -0
- data/lib/appsignal/event_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +2 -0
- data/lib/appsignal/extension.rb +2 -0
- data/lib/appsignal/extension/jruby.rb +15 -13
- data/lib/appsignal/garbage_collection_profiler.rb +2 -0
- data/lib/appsignal/hooks.rb +2 -0
- data/lib/appsignal/hooks/action_cable.rb +2 -0
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -0
- data/lib/appsignal/hooks/celluloid.rb +2 -0
- data/lib/appsignal/hooks/data_mapper.rb +2 -0
- data/lib/appsignal/hooks/delayed_job.rb +2 -0
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/hooks/net_http.rb +2 -0
- data/lib/appsignal/hooks/passenger.rb +2 -0
- data/lib/appsignal/hooks/puma.rb +2 -0
- data/lib/appsignal/hooks/que.rb +2 -0
- data/lib/appsignal/hooks/rake.rb +2 -0
- data/lib/appsignal/hooks/redis.rb +2 -0
- data/lib/appsignal/hooks/sequel.rb +2 -0
- data/lib/appsignal/hooks/shoryuken.rb +6 -2
- data/lib/appsignal/hooks/sidekiq.rb +4 -2
- data/lib/appsignal/hooks/unicorn.rb +2 -0
- data/lib/appsignal/hooks/webmachine.rb +2 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -0
- data/lib/appsignal/integrations/data_mapper.rb +2 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +6 -2
- data/lib/appsignal/integrations/grape.rb +2 -0
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/integrations/object.rb +2 -0
- data/lib/appsignal/integrations/padrino.rb +3 -4
- data/lib/appsignal/integrations/que.rb +2 -0
- data/lib/appsignal/integrations/railtie.rb +2 -0
- data/lib/appsignal/integrations/rake.rb +2 -0
- data/lib/appsignal/integrations/resque.rb +2 -0
- data/lib/appsignal/integrations/resque_active_job.rb +6 -2
- data/lib/appsignal/integrations/sinatra.rb +2 -0
- data/lib/appsignal/integrations/webmachine.rb +2 -0
- data/lib/appsignal/js_exception_transaction.rb +2 -0
- data/lib/appsignal/marker.rb +2 -0
- data/lib/appsignal/minutely.rb +2 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +2 -0
- data/lib/appsignal/rack/js_exception_catcher.rb +2 -0
- data/lib/appsignal/rack/rails_instrumentation.rb +2 -0
- data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -0
- data/lib/appsignal/rack/streaming_listener.rb +2 -0
- data/lib/appsignal/system.rb +2 -0
- data/lib/appsignal/transaction.rb +13 -10
- data/lib/appsignal/transmitter.rb +2 -0
- data/lib/appsignal/utils.rb +3 -1
- data/lib/appsignal/utils/{params_sanitizer.rb → hash_sanitizer.rb} +12 -11
- data/lib/appsignal/utils/query_params_sanitizer.rb +2 -0
- data/lib/appsignal/version.rb +3 -1
- data/lib/sequel/extensions/appsignal_integration.rb +2 -0
- data/resources/appsignal.yml.erb +5 -0
- data/spec/lib/appsignal/auth_check_spec.rb +11 -2
- data/spec/lib/appsignal/cli/install_spec.rb +33 -0
- data/spec/lib/appsignal/config_spec.rb +76 -18
- data/spec/lib/appsignal/extension_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -28
- data/spec/lib/appsignal/transaction_spec.rb +63 -30
- data/spec/lib/appsignal/utils/{params_sanitizer_spec.rb → hash_sanitizer_spec.rb} +6 -6
- data/spec/lib/appsignal_spec.rb +180 -158
- data/spec/support/helpers/std_streams_helper.rb +19 -12
- data/spec/support/project_fixture/config/appsignal.yml +21 -0
- metadata +11 -11
@@ -30,7 +30,7 @@ describe Appsignal::Config do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "config based on the system" do
|
33
|
-
let(:config) { project_fixture_config(:none) }
|
33
|
+
let(:config) { silence { project_fixture_config(:none) } }
|
34
34
|
|
35
35
|
describe ":active" do
|
36
36
|
subject { config[:active] }
|
@@ -76,7 +76,9 @@ describe Appsignal::Config do
|
|
76
76
|
"production",
|
77
77
|
:push_api_key => "abc",
|
78
78
|
:name => "TestApp",
|
79
|
-
:active => true
|
79
|
+
:active => true,
|
80
|
+
:revision => "v2.5.1",
|
81
|
+
:request_headers => []
|
80
82
|
)
|
81
83
|
end
|
82
84
|
|
@@ -88,6 +90,7 @@ describe Appsignal::Config do
|
|
88
90
|
:ignore_errors => [],
|
89
91
|
:ignore_namespaces => [],
|
90
92
|
:filter_parameters => [],
|
93
|
+
:filter_session_data => [],
|
91
94
|
:instrument_net_http => true,
|
92
95
|
:instrument_redis => true,
|
93
96
|
:instrument_sequel => true,
|
@@ -103,10 +106,11 @@ describe Appsignal::Config do
|
|
103
106
|
:enable_gc_instrumentation => false,
|
104
107
|
:enable_host_metrics => true,
|
105
108
|
:enable_minutely_probes => false,
|
106
|
-
:hostname => Socket.gethostname,
|
107
109
|
:ca_file_path => File.join(resources_dir, "cacert.pem"),
|
108
110
|
:dns_servers => [],
|
109
|
-
:files_world_accessible => true
|
111
|
+
:files_world_accessible => true,
|
112
|
+
:revision => "v2.5.1",
|
113
|
+
:request_headers => []
|
110
114
|
)
|
111
115
|
end
|
112
116
|
|
@@ -134,7 +138,8 @@ describe Appsignal::Config do
|
|
134
138
|
described_class.new(
|
135
139
|
"non-existing-path",
|
136
140
|
"production",
|
137
|
-
:active => false
|
141
|
+
:active => false,
|
142
|
+
:request_headers => []
|
138
143
|
)
|
139
144
|
end
|
140
145
|
before { ENV["APPSIGNAL_PUSH_API_KEY"] = "abc" }
|
@@ -298,6 +303,8 @@ describe Appsignal::Config do
|
|
298
303
|
ENV["APPSIGNAL_INSTRUMENT_REDIS"] = "false"
|
299
304
|
ENV["APPSIGNAL_INSTRUMENT_SEQUEL"] = "false"
|
300
305
|
ENV["APPSIGNAL_FILES_WORLD_ACCESSIBLE"] = "false"
|
306
|
+
ENV["APPSIGNAL_REQUEST_HEADERS"] = "accept,accept-charset"
|
307
|
+
ENV["APP_REVISION"] = "v2.5.1"
|
301
308
|
end
|
302
309
|
|
303
310
|
it "overrides config with environment values" do
|
@@ -316,6 +323,8 @@ describe Appsignal::Config do
|
|
316
323
|
expect(config[:instrument_redis]).to eq(false)
|
317
324
|
expect(config[:instrument_sequel]).to eq(false)
|
318
325
|
expect(config[:files_world_accessible]).to eq(false)
|
326
|
+
expect(config[:request_headers]).to eq(%w[accept accept-charset])
|
327
|
+
expect(config[:revision]).to eq("v2.5.1")
|
319
328
|
end
|
320
329
|
|
321
330
|
context "with mixed case `true` env variables values" do
|
@@ -356,7 +365,7 @@ describe Appsignal::Config do
|
|
356
365
|
end
|
357
366
|
|
358
367
|
describe "#[]" do
|
359
|
-
let(:config) { project_fixture_config(:none, :push_api_key => "foo") }
|
368
|
+
let(:config) { project_fixture_config(:none, :push_api_key => "foo", :request_headers => []) }
|
360
369
|
|
361
370
|
context "with existing key" do
|
362
371
|
it "gets the value" do
|
@@ -400,10 +409,10 @@ describe Appsignal::Config do
|
|
400
409
|
config[:ignore_namespaces] = %w[admin private_namespace]
|
401
410
|
config[:log] = "stdout"
|
402
411
|
config[:log_path] = "/tmp"
|
403
|
-
config[:hostname] = "app1.local"
|
404
412
|
config[:filter_parameters] = %w[password confirm_password]
|
405
413
|
config[:running_in_container] = false
|
406
414
|
config[:dns_servers] = ["8.8.8.8", "8.8.4.4"]
|
415
|
+
config[:revision] = "v2.5.1"
|
407
416
|
config.write_to_environment
|
408
417
|
end
|
409
418
|
|
@@ -423,19 +432,30 @@ describe Appsignal::Config do
|
|
423
432
|
expect(ENV["_APPSIGNAL_IGNORE_ACTIONS"]).to eq "action1,action2"
|
424
433
|
expect(ENV["_APPSIGNAL_IGNORE_ERRORS"]).to eq "ExampleStandardError,AnotherError"
|
425
434
|
expect(ENV["_APPSIGNAL_IGNORE_NAMESPACES"]).to eq "admin,private_namespace"
|
426
|
-
expect(ENV["_APPSIGNAL_FILTER_PARAMETERS"]).to eq "password,confirm_password"
|
427
435
|
expect(ENV["_APPSIGNAL_SEND_PARAMS"]).to eq "true"
|
428
436
|
expect(ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"]).to eq "false"
|
429
437
|
expect(ENV["_APPSIGNAL_ENABLE_HOST_METRICS"]).to eq "true"
|
430
438
|
expect(ENV["_APPSIGNAL_ENABLE_MINUTELY_PROBES"]).to eq "false"
|
431
|
-
expect(ENV["_APPSIGNAL_HOSTNAME"]).to eq "
|
439
|
+
expect(ENV["_APPSIGNAL_HOSTNAME"]).to eq ""
|
432
440
|
expect(ENV["_APPSIGNAL_PROCESS_NAME"]).to include "rspec"
|
433
441
|
expect(ENV["_APPSIGNAL_CA_FILE_PATH"]).to eq File.join(resources_dir, "cacert.pem")
|
434
442
|
expect(ENV["_APPSIGNAL_DNS_SERVERS"]).to eq "8.8.8.8,8.8.4.4"
|
435
443
|
expect(ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"]).to eq "true"
|
444
|
+
expect(ENV["_APP_REVISION"]).to eq "v2.5.1"
|
436
445
|
expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
|
437
446
|
end
|
438
447
|
|
448
|
+
context "with :hostname" do
|
449
|
+
before do
|
450
|
+
config[:hostname] = "Alices-MBP.example.com"
|
451
|
+
config.write_to_environment
|
452
|
+
end
|
453
|
+
|
454
|
+
it "sets the modified :hostname" do
|
455
|
+
expect(ENV["_APPSIGNAL_HOSTNAME"]).to eq "Alices-MBP.example.com"
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
439
459
|
context "with :working_dir_path" do
|
440
460
|
before do
|
441
461
|
config[:working_dir_path] = "/tmp/appsignal2"
|
@@ -613,23 +633,61 @@ describe Appsignal::Config do
|
|
613
633
|
end
|
614
634
|
|
615
635
|
describe "#validate" do
|
616
|
-
before { config.validate }
|
617
636
|
subject { config.valid? }
|
618
|
-
let(:config)
|
637
|
+
let(:config) do
|
638
|
+
described_class.new(Dir.pwd, "production", config_options)
|
639
|
+
end
|
619
640
|
|
620
|
-
|
621
|
-
let(:
|
641
|
+
describe "push_api_key" do
|
642
|
+
let(:config_options) { { :push_api_key => push_api_key, :request_headers => [] } }
|
643
|
+
before { config.validate }
|
622
644
|
|
623
|
-
|
624
|
-
|
645
|
+
context "with missing push_api_key" do
|
646
|
+
let(:push_api_key) { nil }
|
647
|
+
|
648
|
+
it "sets valid to false" do
|
649
|
+
is_expected.to eq(false)
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
context "with push_api_key present" do
|
654
|
+
let(:push_api_key) { "abc" }
|
655
|
+
|
656
|
+
it "sets valid to true" do
|
657
|
+
is_expected.to eq(true)
|
658
|
+
end
|
625
659
|
end
|
626
660
|
end
|
627
661
|
|
628
|
-
|
662
|
+
describe "request_headers option validation" do
|
663
|
+
let(:out_stream) { std_stream }
|
664
|
+
let(:output) { out_stream.read }
|
629
665
|
let(:push_api_key) { "abc" }
|
666
|
+
let(:config_options) { { :push_api_key => push_api_key } }
|
667
|
+
before do
|
668
|
+
capture_stdout(out_stream) do
|
669
|
+
config.validate
|
670
|
+
end
|
671
|
+
end
|
630
672
|
|
631
|
-
|
632
|
-
|
673
|
+
context "with missing request_headers config option" do
|
674
|
+
let(:config_options) { { :push_api_key => "abc" } }
|
675
|
+
|
676
|
+
it "logs a warning" do
|
677
|
+
is_expected.to eq(true)
|
678
|
+
expect(output).to include "Warning: The `request_headers` config " \
|
679
|
+
"option was not set in the AppSignal configuration"
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
context "with request_headers config option present" do
|
684
|
+
let(:config_options) { { :push_api_key => "abc", :request_headers => [] } }
|
685
|
+
|
686
|
+
it "logs no warning" do
|
687
|
+
is_expected.to eq(true)
|
688
|
+
expect(output).to_not include "Warning: The `request_headers` config " \
|
689
|
+
"option was not set in the AppSignal configuration"
|
690
|
+
end
|
633
691
|
end
|
634
692
|
end
|
635
693
|
end
|
@@ -103,15 +103,15 @@ describe Appsignal::Extension do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should have a set_gauge method" do
|
106
|
-
subject.set_gauge("key", 1.0)
|
106
|
+
subject.set_gauge("key", 1.0, Appsignal::Extension.data_map_new)
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should have a increment_counter method" do
|
110
|
-
subject.increment_counter("key", 1)
|
110
|
+
subject.increment_counter("key", 1, Appsignal::Extension.data_map_new)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should have a add_distribution_value method" do
|
114
|
-
subject.add_distribution_value("key", 1.0)
|
114
|
+
subject.add_distribution_value("key", 1.0, Appsignal::Extension.data_map_new)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -141,7 +141,7 @@ if DependencyHelper.padrino_present?
|
|
141
141
|
it "instruments the request" do
|
142
142
|
expect_a_transaction_to_be_created
|
143
143
|
# Uses path for action name
|
144
|
-
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp
|
144
|
+
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp#unknown")
|
145
145
|
expect(response).to match_response(404, "<h1>Not Found</h1>")
|
146
146
|
end
|
147
147
|
end
|
@@ -162,52 +162,32 @@ if DependencyHelper.padrino_present?
|
|
162
162
|
|
163
163
|
# Older Padrino versions don't support `action` (v11.0+)
|
164
164
|
context "without #action on Sinatra::Request" do
|
165
|
-
let(:path) { "/my_original_path" }
|
166
|
-
let(:request_kind) do
|
167
|
-
double(
|
168
|
-
:params => {},
|
169
|
-
:path => path,
|
170
|
-
:path_info => path,
|
171
|
-
:request_method => "GET",
|
172
|
-
:head? => false,
|
173
|
-
:route_obj => double(:original_path => "original_path method"),
|
174
|
-
:route_obj= => nil # Make sure route_obj doesn't get overwritten
|
175
|
-
)
|
176
|
-
end
|
165
|
+
let(:path) { "/my_original_path/10" }
|
177
166
|
before do
|
178
|
-
|
179
|
-
app.controllers { get(:my_original_path) { "content" } }
|
167
|
+
allow_any_instance_of(Sinatra::Request).to receive(:action).and_return(nil)
|
168
|
+
app.controllers { get(:my_original_path, :with => :id) { "content" } }
|
180
169
|
end
|
181
170
|
after { expect(response).to match_response(200, "content") }
|
182
171
|
|
183
172
|
it "falls back on Sinatra::Request#route_obj.original_path" do
|
184
173
|
expect_a_transaction_to_be_created
|
185
174
|
expect(transaction)
|
186
|
-
.to receive(:set_action_if_nil).with("PadrinoTestApp
|
175
|
+
.to receive(:set_action_if_nil).with("PadrinoTestApp:/my_original_path/:id")
|
187
176
|
end
|
188
177
|
end
|
189
178
|
|
190
179
|
context "without Sinatra::Request#route_obj.original_path" do
|
191
180
|
let(:path) { "/my_original_path" }
|
192
|
-
let(:request_kind) do
|
193
|
-
double(
|
194
|
-
:params => {},
|
195
|
-
:path => path,
|
196
|
-
:path_info => path,
|
197
|
-
:request_method => "GET",
|
198
|
-
:head? => false,
|
199
|
-
:route_obj= => nil # Make sure route_obj doesn't get overwritten
|
200
|
-
)
|
201
|
-
end
|
202
181
|
before do
|
203
|
-
|
182
|
+
allow_any_instance_of(Sinatra::Request).to receive(:action).and_return(nil)
|
183
|
+
allow_any_instance_of(Sinatra::Request).to receive(:route_obj).and_return(nil)
|
204
184
|
app.controllers { get(:my_original_path) { "content" } }
|
205
185
|
end
|
206
186
|
after { expect(response).to match_response(200, "content") }
|
207
187
|
|
208
188
|
it "falls back on app name" do
|
209
189
|
expect_a_transaction_to_be_created
|
210
|
-
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp")
|
190
|
+
expect(transaction).to receive(:set_action_if_nil).with("PadrinoTestApp#unknown")
|
211
191
|
end
|
212
192
|
end
|
213
193
|
|
@@ -912,8 +912,7 @@ describe Appsignal::Transaction do
|
|
912
912
|
end
|
913
913
|
|
914
914
|
describe "#sanitized_environment" do
|
915
|
-
let(:whitelisted_keys) { Appsignal
|
916
|
-
|
915
|
+
let(:whitelisted_keys) { Appsignal.config[:request_headers] }
|
917
916
|
subject { transaction.send(:sanitized_environment) }
|
918
917
|
|
919
918
|
context "when request is nil" do
|
@@ -940,6 +939,16 @@ describe Appsignal::Transaction do
|
|
940
939
|
it "only sets whitelisted keys" do
|
941
940
|
expect(subject.keys).to match_array(whitelisted_keys)
|
942
941
|
end
|
942
|
+
|
943
|
+
context "with configured request_headers" do
|
944
|
+
before do
|
945
|
+
Appsignal.config.config_hash[:request_headers] = %w[CONTENT_LENGTH]
|
946
|
+
end
|
947
|
+
|
948
|
+
it "only sets whitelisted keys" do
|
949
|
+
expect(subject.keys).to match_array(%w[CONTENT_LENGTH])
|
950
|
+
end
|
951
|
+
end
|
943
952
|
end
|
944
953
|
end
|
945
954
|
|
@@ -970,37 +979,42 @@ describe Appsignal::Transaction do
|
|
970
979
|
it { is_expected.to be_nil }
|
971
980
|
end
|
972
981
|
|
973
|
-
context "
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
allow(transaction).to receive_message_chain(:request, :fullpath => :bar)
|
978
|
-
end
|
982
|
+
context "with a session" do
|
983
|
+
let(:session_data_filter) { [] }
|
984
|
+
before { Appsignal.config[:filter_session_data] = session_data_filter }
|
985
|
+
after { Appsignal.config[:filter_session_data] = [] }
|
979
986
|
|
980
|
-
|
981
|
-
|
982
|
-
.
|
983
|
-
|
984
|
-
|
987
|
+
context "with generic session object" do
|
988
|
+
before do
|
989
|
+
expect(transaction).to respond_to(:request)
|
990
|
+
allow(transaction).to receive_message_chain(
|
991
|
+
:request,
|
992
|
+
:session => { :foo => :bar, :abc => :def }
|
993
|
+
)
|
994
|
+
allow(transaction).to receive_message_chain(:request, :fullpath => :bar)
|
995
|
+
end
|
985
996
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
expect(transaction).to respond_to(:request)
|
990
|
-
allow(transaction).to receive_message_chain(:request, :session => action_dispatch_session)
|
991
|
-
allow(transaction).to receive_message_chain(:request, :fullpath => :bar)
|
997
|
+
context "without session filtering" do
|
998
|
+
it "keeps the session data intact" do
|
999
|
+
expect(subject).to eq(:foo => :bar, :abc => :def)
|
992
1000
|
end
|
1001
|
+
end
|
1002
|
+
|
1003
|
+
context "with session filtering" do
|
1004
|
+
let(:session_data_filter) { %w[foo] }
|
993
1005
|
|
994
|
-
it "
|
995
|
-
expect(
|
996
|
-
.and_return(:sanitized_foo)
|
997
|
-
subject
|
1006
|
+
it "filters the session data" do
|
1007
|
+
expect(subject).to eq(:foo => "[FILTERED]", :abc => :def)
|
998
1008
|
end
|
1009
|
+
end
|
1010
|
+
end
|
999
1011
|
|
1000
|
-
|
1012
|
+
if defined? ActionDispatch::Request::Session
|
1013
|
+
context "with ActionDispatch::Request::Session" do
|
1014
|
+
let(:action_dispatch_session) do
|
1001
1015
|
store = Class.new do
|
1002
1016
|
def load_session(_env)
|
1003
|
-
[1, { :foo => :bar }]
|
1017
|
+
[1, { :foo => :bar, :abc => :def }]
|
1004
1018
|
end
|
1005
1019
|
|
1006
1020
|
def session_exists?(_env)
|
@@ -1009,16 +1023,35 @@ describe Appsignal::Transaction do
|
|
1009
1023
|
end.new
|
1010
1024
|
ActionDispatch::Request::Session.create(store, ActionDispatch::Request.new("rack.input" => StringIO.new), {})
|
1011
1025
|
end
|
1026
|
+
before do
|
1027
|
+
expect(transaction).to respond_to(:request)
|
1028
|
+
allow(transaction).to receive_message_chain(
|
1029
|
+
:request,
|
1030
|
+
:session => action_dispatch_session
|
1031
|
+
)
|
1032
|
+
allow(transaction).to receive_message_chain(:request, :fullpath => :bar)
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
context "without session filtering" do
|
1036
|
+
it "keeps the session data intact" do
|
1037
|
+
expect(subject).to eq("foo" => :bar, "abc" => :def)
|
1038
|
+
end
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
context "with session filtering" do
|
1042
|
+
let(:session_data_filter) { %w[foo] }
|
1043
|
+
|
1044
|
+
it "filters the session data" do
|
1045
|
+
expect(subject).to eq("foo" => "[FILTERED]", "abc" => :def)
|
1046
|
+
end
|
1047
|
+
end
|
1012
1048
|
end
|
1013
1049
|
end
|
1014
1050
|
|
1015
1051
|
context "when skipping session data" do
|
1016
|
-
before
|
1017
|
-
Appsignal.config = { :skip_session_data => true }
|
1018
|
-
end
|
1052
|
+
before { Appsignal.config[:skip_session_data] = true }
|
1019
1053
|
|
1020
|
-
it "does not
|
1021
|
-
expect(Appsignal::Utils::ParamsSanitizer).to_not receive(:sanitize)
|
1054
|
+
it "does not set any session data on the transaction" do
|
1022
1055
|
expect(subject).to be_nil
|
1023
1056
|
end
|
1024
1057
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Appsignal::Utils::
|
1
|
+
describe Appsignal::Utils::HashSanitizer do
|
2
2
|
let(:file) { uploaded_file }
|
3
3
|
let(:params) do
|
4
4
|
{
|
@@ -80,9 +80,9 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
context "with
|
83
|
+
context "with filter_keys" do
|
84
84
|
let(:sanitized_params) do
|
85
|
-
described_class.sanitize(params,
|
85
|
+
described_class.sanitize(params, %w[text hash])
|
86
86
|
end
|
87
87
|
subject { sanitized_params }
|
88
88
|
|
@@ -100,7 +100,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
100
100
|
|
101
101
|
context "with strings as key filter values" do
|
102
102
|
let(:sanitized_params) do
|
103
|
-
described_class.sanitize(params,
|
103
|
+
described_class.sanitize(params, %w[string])
|
104
104
|
end
|
105
105
|
|
106
106
|
it "sanitizes values" do
|
@@ -110,7 +110,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
110
110
|
|
111
111
|
describe ":hash" do
|
112
112
|
let(:sanitized_params) do
|
113
|
-
described_class.sanitize(params,
|
113
|
+
described_class.sanitize(params, %w[nested_text])
|
114
114
|
end
|
115
115
|
subject { sanitized_params[:hash] }
|
116
116
|
|
@@ -121,7 +121,7 @@ describe Appsignal::Utils::ParamsSanitizer do
|
|
121
121
|
describe ":nested_array" do
|
122
122
|
describe ":nested_hash" do
|
123
123
|
let(:sanitized_params) do
|
124
|
-
described_class.sanitize(params,
|
124
|
+
described_class.sanitize(params, %w[key])
|
125
125
|
end
|
126
126
|
subject { sanitized_params[:hash][:nested_array][3] }
|
127
127
|
|