appsignal 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +63 -21
- data/.rubocop_todo.yml +68 -54
- data/.semaphore/semaphore.yml +11 -11
- data/CHANGELOG.md +37 -0
- data/Rakefile +15 -99
- data/appsignal.gemspec +3 -4
- data/bin/appsignal +4 -2
- data/build_matrix.yml +4 -4
- data/ext/._appsignal-agent +0 -0
- data/ext/Rakefile +22 -21
- data/ext/agent.rb +2 -0
- data/ext/base.rb +14 -17
- data/ext/extconf.rb +4 -1
- data/lib/appsignal/auth_check.rb +3 -3
- data/lib/appsignal/capistrano.rb +1 -1
- data/lib/appsignal/cli/demo.rb +5 -2
- data/lib/appsignal/cli/diagnose/paths.rb +4 -1
- data/lib/appsignal/cli/diagnose/utils.rb +7 -3
- data/lib/appsignal/cli/diagnose.rb +7 -5
- data/lib/appsignal/cli/helpers.rb +1 -4
- data/lib/appsignal/cli/install.rb +4 -10
- data/lib/appsignal/cli.rb +3 -2
- data/lib/appsignal/config.rb +105 -102
- data/lib/appsignal/demo.rb +2 -1
- data/lib/appsignal/environment.rb +2 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +2 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +13 -13
- data/lib/appsignal/event_formatter.rb +5 -4
- data/lib/appsignal/extension/jruby.rb +11 -9
- data/lib/appsignal/extension.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +50 -35
- data/lib/appsignal/hooks/action_cable.rb +6 -4
- data/lib/appsignal/hooks/action_mailer.rb +2 -0
- data/lib/appsignal/hooks/active_job.rb +11 -10
- data/lib/appsignal/hooks/active_support_notifications.rb +3 -4
- data/lib/appsignal/hooks/data_mapper.rb +1 -1
- data/lib/appsignal/hooks/gvl.rb +3 -0
- data/lib/appsignal/hooks/http.rb +1 -1
- data/lib/appsignal/hooks/mri.rb +2 -0
- data/lib/appsignal/hooks/net_http.rb +1 -1
- data/lib/appsignal/hooks/que.rb +1 -1
- data/lib/appsignal/hooks/rake.rb +1 -1
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/resque.rb +1 -1
- data/lib/appsignal/hooks/shoryuken.rb +2 -4
- data/lib/appsignal/hooks/sidekiq.rb +1 -1
- data/lib/appsignal/hooks/unicorn.rb +2 -2
- data/lib/appsignal/hooks/webmachine.rb +1 -1
- data/lib/appsignal/hooks.rb +2 -2
- data/lib/appsignal/integrations/active_support_notifications.rb +1 -1
- data/lib/appsignal/integrations/capistrano/appsignal.cap +6 -3
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +5 -4
- data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -5
- data/lib/appsignal/integrations/grape.rb +1 -1
- data/lib/appsignal/integrations/hanami.rb +1 -1
- data/lib/appsignal/integrations/object.rb +2 -3
- data/lib/appsignal/integrations/padrino.rb +2 -4
- data/lib/appsignal/integrations/que.rb +6 -6
- data/lib/appsignal/integrations/railtie.rb +72 -0
- data/lib/appsignal/integrations/sidekiq.rb +9 -11
- data/lib/appsignal/integrations/sinatra.rb +1 -3
- data/lib/appsignal/integrations/webmachine.rb +4 -6
- data/lib/appsignal/logger.rb +31 -6
- data/lib/appsignal/marker.rb +4 -5
- data/lib/appsignal/minutely.rb +7 -7
- data/lib/appsignal/probes/gvl.rb +9 -4
- data/lib/appsignal/probes/helpers.rb +4 -6
- data/lib/appsignal/probes/mri.rb +7 -5
- data/lib/appsignal/probes/sidekiq.rb +3 -0
- data/lib/appsignal/probes.rb +2 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +1 -5
- data/lib/appsignal/rack/sinatra_instrumentation.rb +3 -5
- data/lib/appsignal/rack/streaming_listener.rb +11 -13
- data/lib/appsignal/span.rb +5 -5
- data/lib/appsignal/system.rb +10 -11
- data/lib/appsignal/transaction.rb +49 -25
- data/lib/appsignal/transmitter.rb +4 -2
- data/lib/appsignal/utils/deprecation_message.rb +2 -0
- data/lib/appsignal/utils/hash_sanitizer.rb +1 -1
- data/lib/appsignal/utils/integration_logger.rb +5 -3
- data/lib/appsignal/utils/json.rb +1 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +5 -4
- data/lib/puma/plugin/appsignal.rb +16 -18
- data/script/lint_git +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +6 -3
- data/spec/lib/appsignal/capistrano3_spec.rb +6 -3
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +1 -3
- data/spec/lib/appsignal/cli/diagnose_spec.rb +33 -30
- data/spec/lib/appsignal/cli/install_spec.rb +5 -6
- data/spec/lib/appsignal/cli_spec.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +43 -37
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +11 -5
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +1 -4
- data/spec/lib/appsignal/event_formatter_spec.rb +11 -9
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +5 -2
- data/spec/lib/appsignal/hooks/action_mailer_spec.rb +2 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -1
- data/spec/lib/appsignal/hooks/activejob_spec.rb +21 -12
- data/spec/lib/appsignal/hooks/data_mapper_spec.rb +1 -0
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +12 -12
- data/spec/lib/appsignal/hooks/excon_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -1
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +4 -2
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -1
- data/spec/lib/appsignal/hooks_spec.rb +5 -4
- data/spec/lib/appsignal/integrations/grape_spec.rb +8 -4
- data/spec/lib/appsignal/integrations/hanami_spec.rb +16 -8
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +2 -4
- data/spec/lib/appsignal/integrations/object_spec.rb +6 -1
- data/spec/lib/appsignal/integrations/padrino_spec.rb +4 -2
- data/spec/lib/appsignal/integrations/railtie_spec.rb +213 -6
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +54 -41
- data/spec/lib/appsignal/logger_spec.rb +20 -4
- data/spec/lib/appsignal/marker_spec.rb +2 -2
- data/spec/lib/appsignal/minutely_spec.rb +3 -3
- data/spec/lib/appsignal/probes/gvl_spec.rb +60 -12
- data/spec/lib/appsignal/probes/mri_spec.rb +7 -4
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -1
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +2 -1
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +10 -5
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +7 -5
- data/spec/lib/appsignal/transaction_spec.rb +20 -13
- data/spec/lib/appsignal/utils/data_spec.rb +10 -1
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +11 -11
- data/spec/lib/appsignal/utils/json_spec.rb +4 -2
- data/spec/lib/appsignal_spec.rb +49 -35
- data/spec/lib/puma/appsignal_spec.rb +9 -11
- data/spec/spec_helper.rb +14 -2
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +1 -1
- data/spec/support/helpers/config_helpers.rb +2 -1
- data/spec/support/helpers/dependency_helper.rb +1 -9
- data/spec/support/helpers/std_streams_helper.rb +1 -3
- data/spec/support/helpers/wait_for_helper.rb +2 -3
- data/spec/support/mocks/appsignal_mock.rb +1 -1
- data/spec/support/mocks/fake_gvl_tools.rb +2 -10
- data/spec/support/testing.rb +4 -3
- metadata +9 -135
@@ -99,7 +99,7 @@ describe Appsignal::CLI::Install do
|
|
99
99
|
|
100
100
|
shared_examples "push_api_key validation" do
|
101
101
|
context "without key" do
|
102
|
-
let(:push_api_key) {}
|
102
|
+
let(:push_api_key) { nil }
|
103
103
|
|
104
104
|
it "does not install" do
|
105
105
|
run
|
@@ -178,7 +178,7 @@ describe Appsignal::CLI::Install do
|
|
178
178
|
|
179
179
|
context "with Capfile" do
|
180
180
|
context "when already installed" do
|
181
|
-
before { File.
|
181
|
+
before { File.write(capfile, "require 'appsignal/capistrano'") }
|
182
182
|
|
183
183
|
it "does not add another require to Capfile" do
|
184
184
|
run
|
@@ -432,9 +432,7 @@ describe Appsignal::CLI::Install do
|
|
432
432
|
|
433
433
|
context "when failed to load the Rails application.rb file" do
|
434
434
|
before do
|
435
|
-
File.
|
436
|
-
file.write("I am invalid code")
|
437
|
-
end
|
435
|
+
File.write(File.join(config_dir, "application.rb"), "I am invalid code")
|
438
436
|
end
|
439
437
|
|
440
438
|
it "prompts the user to fill in an app name" do
|
@@ -726,7 +724,8 @@ describe Appsignal::CLI::Install do
|
|
726
724
|
end
|
727
725
|
end
|
728
726
|
|
729
|
-
if !rails_present? && !sinatra_present? && !padrino_present? && !grape_present? &&
|
727
|
+
if !rails_present? && !sinatra_present? && !padrino_present? && !grape_present? &&
|
728
|
+
!hanami2_present?
|
730
729
|
context "with unknown framework" do
|
731
730
|
let(:push_api_key) { "my_key" }
|
732
731
|
|
@@ -162,6 +162,7 @@ describe Appsignal::Config do
|
|
162
162
|
:enable_minutely_probes => true,
|
163
163
|
:enable_statsd => true,
|
164
164
|
:enable_nginx_metrics => false,
|
165
|
+
:enable_rails_error_reporter => true,
|
165
166
|
:endpoint => "https://push.appsignal.com",
|
166
167
|
:files_world_accessible => true,
|
167
168
|
:filter_parameters => [],
|
@@ -263,7 +264,8 @@ describe Appsignal::Config do
|
|
263
264
|
|
264
265
|
context "with an overriden config file" do
|
265
266
|
let(:config) do
|
266
|
-
project_fixture_config("production", {}, Appsignal.logger,
|
267
|
+
project_fixture_config("production", {}, Appsignal.logger,
|
268
|
+
File.join(project_fixture_path, "config", "appsignal.yml"))
|
267
269
|
end
|
268
270
|
|
269
271
|
it "is valid and active" do
|
@@ -273,7 +275,8 @@ describe Appsignal::Config do
|
|
273
275
|
|
274
276
|
context "with an invalid overriden config file" do
|
275
277
|
let(:config) do
|
276
|
-
project_fixture_config("production", {}, Appsignal.logger,
|
278
|
+
project_fixture_config("production", {}, Appsignal.logger,
|
279
|
+
File.join(project_fixture_path, "config", "missing.yml"))
|
277
280
|
end
|
278
281
|
|
279
282
|
it "is not valid" do
|
@@ -612,36 +615,39 @@ describe Appsignal::Config do
|
|
612
615
|
end
|
613
616
|
|
614
617
|
it "writes the current config to environment variables" do
|
615
|
-
expect(ENV
|
616
|
-
expect(ENV
|
617
|
-
|
618
|
-
expect(ENV
|
619
|
-
expect(ENV
|
620
|
-
expect(ENV
|
621
|
-
expect(ENV
|
622
|
-
expect(ENV
|
623
|
-
expect(ENV
|
624
|
-
expect(ENV
|
625
|
-
expect(ENV
|
626
|
-
expect(ENV
|
627
|
-
expect(ENV
|
628
|
-
|
629
|
-
expect(ENV
|
630
|
-
expect(ENV
|
631
|
-
expect(ENV
|
632
|
-
expect(ENV
|
633
|
-
expect(ENV
|
634
|
-
expect(ENV
|
635
|
-
expect(ENV
|
636
|
-
expect(ENV
|
637
|
-
expect(ENV
|
638
|
-
|
639
|
-
expect(ENV
|
640
|
-
expect(ENV
|
641
|
-
expect(ENV
|
642
|
-
expect(ENV
|
643
|
-
expect(ENV
|
644
|
-
expect(ENV
|
618
|
+
expect(ENV.fetch("_APPSIGNAL_ACTIVE", nil)).to eq "true"
|
619
|
+
expect(ENV.fetch("_APPSIGNAL_APP_PATH", nil))
|
620
|
+
.to end_with("spec/support/fixtures/projects/valid")
|
621
|
+
expect(ENV.fetch("_APPSIGNAL_AGENT_PATH", nil)).to end_with("/ext")
|
622
|
+
expect(ENV.fetch("_APPSIGNAL_DEBUG_LOGGING", nil)).to eq "false"
|
623
|
+
expect(ENV.fetch("_APPSIGNAL_LOG", nil)).to eq "stdout"
|
624
|
+
expect(ENV.fetch("_APPSIGNAL_LOG_FILE_PATH", nil)).to end_with("/tmp/appsignal.log")
|
625
|
+
expect(ENV.fetch("_APPSIGNAL_LOGGING_ENDPOINT", nil)).to eq "http://localhost:123"
|
626
|
+
expect(ENV.fetch("_APPSIGNAL_PUSH_API_ENDPOINT", nil)).to eq "https://push.appsignal.com"
|
627
|
+
expect(ENV.fetch("_APPSIGNAL_PUSH_API_KEY", nil)).to eq "abc"
|
628
|
+
expect(ENV.fetch("_APPSIGNAL_APP_NAME", nil)).to eq "TestApp"
|
629
|
+
expect(ENV.fetch("_APPSIGNAL_ENVIRONMENT", nil)).to eq "production"
|
630
|
+
expect(ENV.fetch("_APPSIGNAL_LANGUAGE_INTEGRATION_VERSION", nil))
|
631
|
+
.to eq "ruby-#{Appsignal::VERSION}"
|
632
|
+
expect(ENV.fetch("_APPSIGNAL_HTTP_PROXY", nil)).to eq "http://localhost"
|
633
|
+
expect(ENV.fetch("_APPSIGNAL_IGNORE_ACTIONS", nil)).to eq "action1,action2"
|
634
|
+
expect(ENV.fetch("_APPSIGNAL_IGNORE_ERRORS", nil)).to eq "ExampleStandardError,AnotherError"
|
635
|
+
expect(ENV.fetch("_APPSIGNAL_IGNORE_NAMESPACES", nil)).to eq "admin,private_namespace"
|
636
|
+
expect(ENV.fetch("_APPSIGNAL_RUNNING_IN_CONTAINER", nil)).to eq "false"
|
637
|
+
expect(ENV.fetch("_APPSIGNAL_ENABLE_HOST_METRICS", nil)).to eq "true"
|
638
|
+
expect(ENV.fetch("_APPSIGNAL_HOSTNAME", nil)).to eq ""
|
639
|
+
expect(ENV.fetch("_APPSIGNAL_PROCESS_NAME", nil)).to include "rspec"
|
640
|
+
expect(ENV.fetch("_APPSIGNAL_CA_FILE_PATH", nil))
|
641
|
+
.to eq File.join(resources_dir, "cacert.pem")
|
642
|
+
expect(ENV.fetch("_APPSIGNAL_DNS_SERVERS", nil)).to eq "8.8.8.8,8.8.4.4"
|
643
|
+
expect(ENV.fetch("_APPSIGNAL_FILES_WORLD_ACCESSIBLE", nil)).to eq "true"
|
644
|
+
expect(ENV.fetch("_APPSIGNAL_TRANSACTION_DEBUG_MODE", nil)).to eq "true"
|
645
|
+
expect(ENV.fetch("_APPSIGNAL_SEND_ENVIRONMENT_METADATA", nil)).to eq "false"
|
646
|
+
expect(ENV.fetch("_APPSIGNAL_FILTER_PARAMETERS", nil)).to eq "password,confirm_password"
|
647
|
+
expect(ENV.fetch("_APPSIGNAL_FILTER_SESSION_DATA", nil)).to eq "key1,key2"
|
648
|
+
expect(ENV.fetch("_APP_REVISION", nil)).to eq "v2.5.1"
|
649
|
+
expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
|
650
|
+
expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIRECTORY_PATH")
|
645
651
|
end
|
646
652
|
|
647
653
|
context "with :hostname" do
|
@@ -651,7 +657,7 @@ describe Appsignal::Config do
|
|
651
657
|
end
|
652
658
|
|
653
659
|
it "sets the modified :hostname" do
|
654
|
-
expect(ENV
|
660
|
+
expect(ENV.fetch("_APPSIGNAL_HOSTNAME", nil)).to eq "Alices-MBP.example.com"
|
655
661
|
end
|
656
662
|
end
|
657
663
|
|
@@ -662,7 +668,7 @@ describe Appsignal::Config do
|
|
662
668
|
end
|
663
669
|
|
664
670
|
it "sets the modified :working_dir_path" do
|
665
|
-
expect(ENV
|
671
|
+
expect(ENV.fetch("_APPSIGNAL_WORKING_DIR_PATH", nil)).to eq "/tmp/appsignal2"
|
666
672
|
end
|
667
673
|
end
|
668
674
|
|
@@ -673,7 +679,7 @@ describe Appsignal::Config do
|
|
673
679
|
end
|
674
680
|
|
675
681
|
it "sets the modified :working_directory_path" do
|
676
|
-
expect(ENV
|
682
|
+
expect(ENV.fetch("_APPSIGNAL_WORKING_DIRECTORY_PATH", nil)).to eq "/tmp/appsignal2"
|
677
683
|
end
|
678
684
|
end
|
679
685
|
end
|
@@ -713,7 +719,7 @@ describe Appsignal::Config do
|
|
713
719
|
|
714
720
|
it "prints a warning" do
|
715
721
|
subject
|
716
|
-
expect(output).to include "appsignal: Unable to log to '#{log_path}'. "\
|
722
|
+
expect(output).to include "appsignal: Unable to log to '#{log_path}'. " \
|
717
723
|
"Logging to '#{system_tmp_dir}' instead."
|
718
724
|
end
|
719
725
|
end
|
@@ -727,7 +733,7 @@ describe Appsignal::Config do
|
|
727
733
|
|
728
734
|
it "prints a warning" do
|
729
735
|
subject
|
730
|
-
expect(output).to include "appsignal: Unable to log to '#{log_path}' "\
|
736
|
+
expect(output).to include "appsignal: Unable to log to '#{log_path}' " \
|
731
737
|
"or the '#{system_tmp_dir}' fallback."
|
732
738
|
end
|
733
739
|
end
|
@@ -9,8 +9,10 @@ describe Appsignal::EventFormatter::ActionView::RenderFormatter do
|
|
9
9
|
before { allow(Rails.root).to receive(:to_s).and_return("/var/www/app/20130101") }
|
10
10
|
|
11
11
|
it "registers render_partial.action_view and render_template.action_view" do
|
12
|
-
expect(Appsignal::EventFormatter.registered?("render_partial.action_view",
|
13
|
-
|
12
|
+
expect(Appsignal::EventFormatter.registered?("render_partial.action_view",
|
13
|
+
klass)).to be_truthy
|
14
|
+
expect(Appsignal::EventFormatter.registered?("render_template.action_view",
|
15
|
+
klass)).to be_truthy
|
14
16
|
end
|
15
17
|
|
16
18
|
describe "#root_path" do
|
@@ -31,7 +33,9 @@ describe Appsignal::EventFormatter::ActionView::RenderFormatter do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
context "with a frozen identifier" do
|
34
|
-
let(:payload)
|
36
|
+
let(:payload) do
|
37
|
+
{ :identifier => "/var/www/app/20130101/app/views/home/index/html.erb".freeze }
|
38
|
+
end
|
35
39
|
|
36
40
|
it { is_expected.to eq ["app/views/home/index/html.erb", nil] }
|
37
41
|
end
|
@@ -46,8 +50,10 @@ describe Appsignal::EventFormatter::ActionView::RenderFormatter do
|
|
46
50
|
else
|
47
51
|
context "when not in a Rails app" do
|
48
52
|
it "does not register the event formatter" do
|
49
|
-
expect(Appsignal::EventFormatter.registered?("render_partial.action_view",
|
50
|
-
|
53
|
+
expect(Appsignal::EventFormatter.registered?("render_partial.action_view",
|
54
|
+
klass)).to be_falsy
|
55
|
+
expect(Appsignal::EventFormatter.registered?("render_template.action_view",
|
56
|
+
klass)).to be_falsy
|
51
57
|
end
|
52
58
|
end
|
53
59
|
end
|
@@ -11,8 +11,8 @@ describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do
|
|
11
11
|
describe "#format" do
|
12
12
|
let(:payload) do
|
13
13
|
{
|
14
|
-
:name
|
15
|
-
:klass
|
14
|
+
:name => "Search",
|
15
|
+
:klass => "User",
|
16
16
|
:search => { :index => "users", :type => "user", :q => "John Doe" }
|
17
17
|
}
|
18
18
|
end
|
@@ -29,8 +29,8 @@ describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do
|
|
29
29
|
let(:search) do
|
30
30
|
{
|
31
31
|
:index => "users",
|
32
|
-
:type
|
33
|
-
:q
|
32
|
+
:type => "user",
|
33
|
+
:q => "John Doe",
|
34
34
|
:other => "Other"
|
35
35
|
}
|
36
36
|
end
|
@@ -5,7 +5,7 @@ describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
|
|
5
5
|
let(:strategy) { :find }
|
6
6
|
let(:command) do
|
7
7
|
{
|
8
|
-
"find"
|
8
|
+
"find" => "users",
|
9
9
|
"filter" => { "_id" => 1 }
|
10
10
|
}
|
11
11
|
end
|
@@ -13,11 +13,8 @@ describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
|
|
13
13
|
it "should apply a strategy for each key" do
|
14
14
|
# TODO: additional curly brackets required for issue
|
15
15
|
# https://github.com/rspec/rspec-mocks/issues/1460
|
16
|
-
# rubocop:disable Style/BracesAroundHashParameters
|
17
16
|
expect(formatter).to receive(:apply_strategy)
|
18
17
|
.with(:sanitize_document, { "_id" => 1 })
|
19
|
-
# rubocop:enable Style/BracesAroundHashParameters
|
20
|
-
|
21
18
|
expect(formatter).to receive(:apply_strategy)
|
22
19
|
.with(:allow, "users")
|
23
20
|
|
@@ -2,6 +2,7 @@ class MockFormatter < Appsignal::EventFormatter
|
|
2
2
|
attr_reader :body
|
3
3
|
|
4
4
|
def initialize
|
5
|
+
super
|
5
6
|
@body = "some value"
|
6
7
|
end
|
7
8
|
|
@@ -28,6 +29,7 @@ end
|
|
28
29
|
|
29
30
|
class MockDependentFormatter < Appsignal::EventFormatter
|
30
31
|
def initialize
|
32
|
+
super
|
31
33
|
raise "There is an error"
|
32
34
|
end
|
33
35
|
|
@@ -60,7 +62,7 @@ describe Appsignal::EventFormatter do
|
|
60
62
|
klass.register("mock.twice", MockFormatter)
|
61
63
|
end
|
62
64
|
expect(klass.registered?("mock.twice")).to be_truthy
|
63
|
-
expect(logs).to contains_log :warn,
|
65
|
+
expect(logs).to contains_log :warn,
|
64
66
|
"Formatter for 'mock.twice' already registered, not registering 'MockFormatter'"
|
65
67
|
end
|
66
68
|
end
|
@@ -71,9 +73,9 @@ describe Appsignal::EventFormatter do
|
|
71
73
|
described_class.register "mock.dependent", MockDependentFormatter
|
72
74
|
end
|
73
75
|
expect(klass.registered?("mock.dependent")).to be_falsy
|
74
|
-
expect(logs).to contains_log :error,
|
76
|
+
expect(logs).to contains_log :error,
|
75
77
|
"'There is an error' " \
|
76
|
-
|
78
|
+
"when initializing mock.dependent event formatter"
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -84,9 +86,9 @@ describe Appsignal::EventFormatter do
|
|
84
86
|
described_class.register "mock.missing", MissingFormatMockFormatter
|
85
87
|
end
|
86
88
|
expect(klass.registered?("mock.missing")).to be_falsy
|
87
|
-
expect(logs).to contains_log :error,
|
89
|
+
expect(logs).to contains_log :error,
|
88
90
|
"'MissingFormatMockFormatter does not have a format(payload) " \
|
89
|
-
|
91
|
+
"method' when initializing mock.missing event formatter"
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
@@ -96,9 +98,9 @@ describe Appsignal::EventFormatter do
|
|
96
98
|
described_class.register "mock.incorrect", IncorrectFormatMockFormatter
|
97
99
|
end
|
98
100
|
expect(klass.registered?("mock.incorrect")).to be_falsy
|
99
|
-
expect(logs).to contains_log :error,
|
101
|
+
expect(logs).to contains_log :error,
|
100
102
|
"'IncorrectFormatMockFormatter does not have a format(payload) " \
|
101
|
-
|
103
|
+
"method' when initializing mock.incorrect event formatter"
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
@@ -108,9 +110,9 @@ describe Appsignal::EventFormatter do
|
|
108
110
|
described_class.register "mock.incorrect", IncorrectFormatMock2Formatter
|
109
111
|
end
|
110
112
|
expect(klass.registered?("mock.incorrect")).to be_falsy
|
111
|
-
expect(logs).to contains_log :error,
|
113
|
+
expect(logs).to contains_log :error,
|
112
114
|
"'IncorrectFormatMock2Formatter does not have a format(payload) " \
|
113
|
-
|
115
|
+
"method' when initializing mock.incorrect event formatter"
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -52,8 +52,11 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
52
52
|
expect(Appsignal.active?).to be_truthy
|
53
53
|
transaction
|
54
54
|
|
55
|
-
expect(Appsignal::Transaction).to receive(:create)
|
56
|
-
|
55
|
+
expect(Appsignal::Transaction).to receive(:create).with(
|
56
|
+
transaction_id,
|
57
|
+
Appsignal::Transaction::ACTION_CABLE,
|
58
|
+
kind_of(ActionDispatch::Request)
|
59
|
+
)
|
57
60
|
.and_return(transaction)
|
58
61
|
allow(Appsignal::Transaction).to receive(:current).and_return(transaction)
|
59
62
|
|
@@ -8,7 +8,8 @@ describe Appsignal::Hooks::ActionMailerHook do
|
|
8
8
|
default :from => "test@example.com"
|
9
9
|
|
10
10
|
def welcome
|
11
|
-
mail(:to => "test@example.com", :subject => "ActionMailer test",
|
11
|
+
mail(:to => "test@example.com", :subject => "ActionMailer test",
|
12
|
+
:content_type => "text/html") do |format|
|
12
13
|
format.html { render :html => "This is a test" }
|
13
14
|
end
|
14
15
|
end
|
@@ -48,7 +48,7 @@ shared_examples "activesupport instrument override" do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it "converts non-string names to strings" do
|
51
|
-
as.instrument(:not_a_string) {}
|
51
|
+
as.instrument(:not_a_string) {} # rubocop:disable Lint/EmptyBlock
|
52
52
|
expect(transaction.to_h["events"]).to match([
|
53
53
|
{
|
54
54
|
"allocation_count" => kind_of(Integer),
|
@@ -1,7 +1,7 @@
|
|
1
1
|
shared_examples "activesupport start finish override" do
|
2
2
|
let(:instrumenter) { as.instrumenter }
|
3
3
|
|
4
|
-
it "instruments
|
4
|
+
it "instruments start/finish events with payload on start ignores payload" do
|
5
5
|
instrumenter.start("sql.active_record", :sql => "SQL")
|
6
6
|
instrumenter.finish("sql.active_record", {})
|
7
7
|
|
@@ -167,7 +167,8 @@ if DependencyHelper.active_job_present?
|
|
167
167
|
expect(Appsignal).to receive(:increment_counter)
|
168
168
|
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
169
169
|
expect(Appsignal).to receive(:increment_counter)
|
170
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
170
|
+
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
171
|
+
:status => :processed))
|
171
172
|
|
172
173
|
perform_job(ActiveJobPriorityTestJob)
|
173
174
|
|
@@ -243,9 +244,11 @@ if DependencyHelper.active_job_present?
|
|
243
244
|
expect(Appsignal).to receive(:increment_counter)
|
244
245
|
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
245
246
|
expect(Appsignal).to receive(:increment_counter)
|
246
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
247
|
+
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
248
|
+
:status => :processed))
|
247
249
|
expect(Appsignal).to receive(:increment_counter)
|
248
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
250
|
+
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
251
|
+
:status => :failed))
|
249
252
|
|
250
253
|
expect do
|
251
254
|
perform_job(ActiveJobErrorPriorityTestJob)
|
@@ -323,7 +326,8 @@ if DependencyHelper.active_job_present?
|
|
323
326
|
end
|
324
327
|
end
|
325
328
|
|
326
|
-
context "with provider_job_id",
|
329
|
+
context "with provider_job_id",
|
330
|
+
:skip => DependencyHelper.rails_version < Gem::Version.new("5.0.0") do
|
327
331
|
before do
|
328
332
|
module ActiveJob
|
329
333
|
module QueueAdapters
|
@@ -363,7 +367,8 @@ if DependencyHelper.active_job_present?
|
|
363
367
|
end
|
364
368
|
end
|
365
369
|
|
366
|
-
context "with enqueued_at",
|
370
|
+
context "with enqueued_at",
|
371
|
+
:skip => DependencyHelper.rails_version < Gem::Version.new("6.0.0") do
|
367
372
|
before do
|
368
373
|
module ActiveJob
|
369
374
|
module QueueAdapters
|
@@ -425,7 +430,8 @@ if DependencyHelper.active_job_present?
|
|
425
430
|
expect(transaction_hash).to include(
|
426
431
|
"action" => "ActionMailerTestJob#welcome",
|
427
432
|
"sample_data" => hash_including(
|
428
|
-
"params" => ["ActionMailerTestJob", "welcome",
|
433
|
+
"params" => ["ActionMailerTestJob", "welcome",
|
434
|
+
"deliver_now"] + active_job_args_wrapper,
|
429
435
|
"tags" => {
|
430
436
|
"active_job_id" => kind_of(String),
|
431
437
|
"queue" => "mailers"
|
@@ -444,7 +450,8 @@ if DependencyHelper.active_job_present?
|
|
444
450
|
expect(transaction_hash).to include(
|
445
451
|
"action" => "ActionMailerTestJob#welcome",
|
446
452
|
"sample_data" => hash_including(
|
447
|
-
"params" => ["ActionMailerTestJob", "welcome",
|
453
|
+
"params" => ["ActionMailerTestJob", "welcome",
|
454
|
+
"deliver_now"] + active_job_args_wrapper(:args => method_expected_args),
|
448
455
|
"tags" => {
|
449
456
|
"active_job_id" => kind_of(String),
|
450
457
|
"queue" => "mailers"
|
@@ -464,7 +471,11 @@ if DependencyHelper.active_job_present?
|
|
464
471
|
expect(transaction_hash).to include(
|
465
472
|
"action" => "ActionMailerTestJob#welcome",
|
466
473
|
"sample_data" => hash_including(
|
467
|
-
"params" => [
|
474
|
+
"params" => [
|
475
|
+
"ActionMailerTestJob",
|
476
|
+
"welcome",
|
477
|
+
"deliver_now"
|
478
|
+
] + active_job_args_wrapper(:params => parameterized_expected_args),
|
468
479
|
"tags" => {
|
469
480
|
"active_job_id" => kind_of(String),
|
470
481
|
"queue" => "mailers"
|
@@ -571,10 +582,8 @@ if DependencyHelper.active_job_present?
|
|
571
582
|
end
|
572
583
|
end
|
573
584
|
|
574
|
-
def perform_active_job
|
575
|
-
Timecop.freeze(time)
|
576
|
-
yield
|
577
|
-
end
|
585
|
+
def perform_active_job(&block)
|
586
|
+
Timecop.freeze(time, &block)
|
578
587
|
end
|
579
588
|
|
580
589
|
def perform_job(job_class, args = nil)
|
@@ -39,13 +39,13 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
39
39
|
let(:payload_object) { double(:args => args) }
|
40
40
|
let(:job_data) do
|
41
41
|
{
|
42
|
-
:id
|
43
|
-
:name
|
44
|
-
:priority
|
45
|
-
:attempts
|
46
|
-
:queue
|
47
|
-
:created_at
|
48
|
-
:run_at
|
42
|
+
:id => 123,
|
43
|
+
:name => "TestClass#perform",
|
44
|
+
:priority => 1,
|
45
|
+
:attempts => 1,
|
46
|
+
:queue => "default",
|
47
|
+
:created_at => created_at,
|
48
|
+
:run_at => run_at,
|
49
49
|
:payload_object => payload_object
|
50
50
|
}
|
51
51
|
end
|
@@ -76,8 +76,8 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
76
76
|
"metadata" => {
|
77
77
|
"priority" => 1,
|
78
78
|
"attempts" => 1,
|
79
|
-
"queue"
|
80
|
-
"id"
|
79
|
+
"queue" => "default",
|
80
|
+
"id" => "123"
|
81
81
|
},
|
82
82
|
"params" => ["argument"]
|
83
83
|
)
|
@@ -204,7 +204,7 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
context "with payload_object
|
207
|
+
context "with payload_object acting like a Hash and returning a non-String value" do
|
208
208
|
class ClassActingAsHash
|
209
209
|
def self.[](_key)
|
210
210
|
Object.new
|
@@ -279,8 +279,8 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
279
279
|
"metadata" => {
|
280
280
|
"priority" => 1,
|
281
281
|
"attempts" => 1,
|
282
|
-
"queue"
|
283
|
-
"id"
|
282
|
+
"queue" => "default",
|
283
|
+
"id" => "123"
|
284
284
|
},
|
285
285
|
"params" => ["activejob_argument"]
|
286
286
|
)
|
@@ -38,7 +38,7 @@ describe Appsignal::Hooks::ExconHook do
|
|
38
38
|
:method => :get,
|
39
39
|
:scheme => "http"
|
40
40
|
}
|
41
|
-
Excon.defaults[:instrumentor].instrument("excon.request", data) {}
|
41
|
+
Excon.defaults[:instrumentor].instrument("excon.request", data) {} # rubocop:disable Lint/EmptyBlock
|
42
42
|
|
43
43
|
expect(transaction.to_h["events"]).to include(
|
44
44
|
hash_including(
|
@@ -51,7 +51,7 @@ describe Appsignal::Hooks::ExconHook do
|
|
51
51
|
|
52
52
|
it "instruments a http response" do
|
53
53
|
data = { :host => "www.google.com" }
|
54
|
-
Excon.defaults[:instrumentor].instrument("excon.response", data) {}
|
54
|
+
Excon.defaults[:instrumentor].instrument("excon.response", data) {} # rubocop:disable Lint/EmptyBlock
|
55
55
|
|
56
56
|
expect(transaction.to_h["events"]).to include(
|
57
57
|
hash_including(
|
@@ -3,7 +3,9 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
|
|
3
3
|
|
4
4
|
context "with mongo ruby driver" do
|
5
5
|
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
6
|
-
before
|
6
|
+
before do
|
7
|
+
allow(Appsignal::Hooks::MongoMonitorSubscriber).to receive(:new).and_return(subscriber)
|
8
|
+
end
|
7
9
|
|
8
10
|
before(:context) do
|
9
11
|
module Mongo
|
@@ -146,7 +146,9 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
|
|
146
146
|
[
|
147
147
|
double(
|
148
148
|
:message_id => "msg2",
|
149
|
-
:attributes => {
|
149
|
+
:attributes => {
|
150
|
+
"SentTimestamp" => (Time.parse("1976-11-18 01:00:00UTC").to_i * 1000).to_s
|
151
|
+
}
|
150
152
|
),
|
151
153
|
double(
|
152
154
|
:message_id => "msg1",
|
@@ -165,7 +167,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
|
|
165
167
|
it "creates a transaction for the batch" do
|
166
168
|
allow_any_instance_of(Appsignal::Transaction).to receive(:set_queue_start).and_call_original
|
167
169
|
expect do
|
168
|
-
perform_job {}
|
170
|
+
perform_job {} # rubocop:disable Lint/EmptyBlock
|
169
171
|
end.to change { created_transactions.length }.by(1)
|
170
172
|
|
171
173
|
transaction = last_transaction
|
@@ -67,13 +67,14 @@ describe Appsignal::Hooks do
|
|
67
67
|
expect(Appsignal::Hooks.hooks[:mock_error_hook]).to be_instance_of(MockErrorHook)
|
68
68
|
expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
|
69
69
|
|
70
|
-
expect(Appsignal.logger).to receive(:error)
|
70
|
+
expect(Appsignal.logger).to receive(:error)
|
71
|
+
.with("Error while installing mock_error_hook hook: error").once
|
71
72
|
expect(Appsignal.logger).to receive(:debug).ordered do |message|
|
72
73
|
expect(message).to eq("Installing mock_error_hook hook")
|
73
74
|
end
|
74
75
|
expect(Appsignal.logger).to receive(:debug).ordered do |message|
|
75
76
|
# Start of the error backtrace as debug log
|
76
|
-
expect(message).to start_with(File.expand_path("
|
77
|
+
expect(message).to start_with(File.expand_path("../../..", __dir__))
|
77
78
|
end
|
78
79
|
|
79
80
|
Appsignal::Hooks.load_hooks
|
@@ -104,8 +105,8 @@ describe Appsignal::Hooks do
|
|
104
105
|
|
105
106
|
deprecation_message =
|
106
107
|
"The constant Appsignal::Hooks::SidekiqPlugin has been deprecated. " \
|
107
|
-
|
108
|
-
|
108
|
+
"Please update the constant name to Appsignal::Integrations::SidekiqMiddleware " \
|
109
|
+
"in the following file to remove this message.\n#{__FILE__}:"
|
109
110
|
expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
|
110
111
|
expect(log).to contains_log :warn, deprecation_message
|
111
112
|
end
|