appsignal 3.4.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +63 -21
  3. data/.rubocop_todo.yml +68 -54
  4. data/.semaphore/semaphore.yml +11 -11
  5. data/CHANGELOG.md +37 -0
  6. data/Rakefile +15 -99
  7. data/appsignal.gemspec +3 -4
  8. data/bin/appsignal +4 -2
  9. data/build_matrix.yml +4 -4
  10. data/ext/._appsignal-agent +0 -0
  11. data/ext/Rakefile +22 -21
  12. data/ext/agent.rb +2 -0
  13. data/ext/base.rb +14 -17
  14. data/ext/extconf.rb +4 -1
  15. data/lib/appsignal/auth_check.rb +3 -3
  16. data/lib/appsignal/capistrano.rb +1 -1
  17. data/lib/appsignal/cli/demo.rb +5 -2
  18. data/lib/appsignal/cli/diagnose/paths.rb +4 -1
  19. data/lib/appsignal/cli/diagnose/utils.rb +7 -3
  20. data/lib/appsignal/cli/diagnose.rb +7 -5
  21. data/lib/appsignal/cli/helpers.rb +1 -4
  22. data/lib/appsignal/cli/install.rb +4 -10
  23. data/lib/appsignal/cli.rb +3 -2
  24. data/lib/appsignal/config.rb +105 -102
  25. data/lib/appsignal/demo.rb +2 -1
  26. data/lib/appsignal/environment.rb +2 -0
  27. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +2 -1
  28. data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +13 -13
  29. data/lib/appsignal/event_formatter.rb +5 -4
  30. data/lib/appsignal/extension/jruby.rb +11 -9
  31. data/lib/appsignal/extension.rb +1 -1
  32. data/lib/appsignal/helpers/instrumentation.rb +50 -35
  33. data/lib/appsignal/hooks/action_cable.rb +6 -4
  34. data/lib/appsignal/hooks/action_mailer.rb +2 -0
  35. data/lib/appsignal/hooks/active_job.rb +11 -10
  36. data/lib/appsignal/hooks/active_support_notifications.rb +3 -4
  37. data/lib/appsignal/hooks/data_mapper.rb +1 -1
  38. data/lib/appsignal/hooks/gvl.rb +3 -0
  39. data/lib/appsignal/hooks/http.rb +1 -1
  40. data/lib/appsignal/hooks/mri.rb +2 -0
  41. data/lib/appsignal/hooks/net_http.rb +1 -1
  42. data/lib/appsignal/hooks/que.rb +1 -1
  43. data/lib/appsignal/hooks/rake.rb +1 -1
  44. data/lib/appsignal/hooks/redis.rb +1 -1
  45. data/lib/appsignal/hooks/resque.rb +1 -1
  46. data/lib/appsignal/hooks/shoryuken.rb +2 -4
  47. data/lib/appsignal/hooks/sidekiq.rb +1 -1
  48. data/lib/appsignal/hooks/unicorn.rb +2 -2
  49. data/lib/appsignal/hooks/webmachine.rb +1 -1
  50. data/lib/appsignal/hooks.rb +2 -2
  51. data/lib/appsignal/integrations/active_support_notifications.rb +1 -1
  52. data/lib/appsignal/integrations/capistrano/appsignal.cap +6 -3
  53. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +5 -4
  54. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -5
  55. data/lib/appsignal/integrations/grape.rb +1 -1
  56. data/lib/appsignal/integrations/hanami.rb +1 -1
  57. data/lib/appsignal/integrations/object.rb +2 -3
  58. data/lib/appsignal/integrations/padrino.rb +2 -4
  59. data/lib/appsignal/integrations/que.rb +6 -6
  60. data/lib/appsignal/integrations/railtie.rb +72 -0
  61. data/lib/appsignal/integrations/sidekiq.rb +9 -11
  62. data/lib/appsignal/integrations/sinatra.rb +1 -3
  63. data/lib/appsignal/integrations/webmachine.rb +4 -6
  64. data/lib/appsignal/logger.rb +31 -6
  65. data/lib/appsignal/marker.rb +4 -5
  66. data/lib/appsignal/minutely.rb +7 -7
  67. data/lib/appsignal/probes/gvl.rb +9 -4
  68. data/lib/appsignal/probes/helpers.rb +4 -6
  69. data/lib/appsignal/probes/mri.rb +7 -5
  70. data/lib/appsignal/probes/sidekiq.rb +3 -0
  71. data/lib/appsignal/probes.rb +2 -0
  72. data/lib/appsignal/rack/generic_instrumentation.rb +1 -5
  73. data/lib/appsignal/rack/sinatra_instrumentation.rb +3 -5
  74. data/lib/appsignal/rack/streaming_listener.rb +11 -13
  75. data/lib/appsignal/span.rb +5 -5
  76. data/lib/appsignal/system.rb +10 -11
  77. data/lib/appsignal/transaction.rb +49 -25
  78. data/lib/appsignal/transmitter.rb +4 -2
  79. data/lib/appsignal/utils/deprecation_message.rb +2 -0
  80. data/lib/appsignal/utils/hash_sanitizer.rb +1 -1
  81. data/lib/appsignal/utils/integration_logger.rb +5 -3
  82. data/lib/appsignal/utils/json.rb +1 -1
  83. data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
  84. data/lib/appsignal/version.rb +1 -1
  85. data/lib/appsignal.rb +5 -4
  86. data/lib/puma/plugin/appsignal.rb +16 -18
  87. data/script/lint_git +1 -1
  88. data/spec/lib/appsignal/capistrano2_spec.rb +6 -3
  89. data/spec/lib/appsignal/capistrano3_spec.rb +6 -3
  90. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +1 -3
  91. data/spec/lib/appsignal/cli/diagnose_spec.rb +33 -30
  92. data/spec/lib/appsignal/cli/install_spec.rb +5 -6
  93. data/spec/lib/appsignal/cli_spec.rb +1 -1
  94. data/spec/lib/appsignal/config_spec.rb +43 -37
  95. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +11 -5
  96. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +4 -4
  97. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +1 -4
  98. data/spec/lib/appsignal/event_formatter_spec.rb +11 -9
  99. data/spec/lib/appsignal/hooks/action_cable_spec.rb +5 -2
  100. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +2 -1
  101. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  102. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -1
  103. data/spec/lib/appsignal/hooks/activejob_spec.rb +21 -12
  104. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +1 -0
  105. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +12 -12
  106. data/spec/lib/appsignal/hooks/excon_spec.rb +2 -2
  107. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -1
  108. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +4 -2
  109. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -1
  110. data/spec/lib/appsignal/hooks_spec.rb +5 -4
  111. data/spec/lib/appsignal/integrations/grape_spec.rb +8 -4
  112. data/spec/lib/appsignal/integrations/hanami_spec.rb +16 -8
  113. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +2 -4
  114. data/spec/lib/appsignal/integrations/object_spec.rb +6 -1
  115. data/spec/lib/appsignal/integrations/padrino_spec.rb +4 -2
  116. data/spec/lib/appsignal/integrations/railtie_spec.rb +213 -6
  117. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +54 -41
  118. data/spec/lib/appsignal/logger_spec.rb +20 -4
  119. data/spec/lib/appsignal/marker_spec.rb +2 -2
  120. data/spec/lib/appsignal/minutely_spec.rb +3 -3
  121. data/spec/lib/appsignal/probes/gvl_spec.rb +60 -12
  122. data/spec/lib/appsignal/probes/mri_spec.rb +7 -4
  123. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -1
  124. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +2 -1
  125. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +10 -5
  126. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +7 -5
  127. data/spec/lib/appsignal/transaction_spec.rb +20 -13
  128. data/spec/lib/appsignal/utils/data_spec.rb +10 -1
  129. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +11 -11
  130. data/spec/lib/appsignal/utils/json_spec.rb +4 -2
  131. data/spec/lib/appsignal_spec.rb +49 -35
  132. data/spec/lib/puma/appsignal_spec.rb +9 -11
  133. data/spec/spec_helper.rb +14 -2
  134. data/spec/support/fixtures/projects/valid/config/appsignal.yml +1 -1
  135. data/spec/support/helpers/config_helpers.rb +2 -1
  136. data/spec/support/helpers/dependency_helper.rb +1 -9
  137. data/spec/support/helpers/std_streams_helper.rb +1 -3
  138. data/spec/support/helpers/wait_for_helper.rb +2 -3
  139. data/spec/support/mocks/appsignal_mock.rb +1 -1
  140. data/spec/support/mocks/fake_gvl_tools.rb +2 -10
  141. data/spec/support/testing.rb +4 -3
  142. 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.open(capfile, "w") { |f| f.write("require 'appsignal/capistrano'") } }
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.open(File.join(config_dir, "application.rb"), "w") do |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? && !hanami2_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
 
@@ -40,7 +40,7 @@ describe Appsignal::CLI do
40
40
  end
41
41
  end.to raise_error(SystemExit)
42
42
 
43
- expect(output).to include "Command 'nonsense' does not exist, run "\
43
+ expect(output).to include "Command 'nonsense' does not exist, run " \
44
44
  "appsignal -h to see the help"
45
45
  end
46
46
 
@@ -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, File.join(project_fixture_path, "config", "appsignal.yml"))
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, File.join(project_fixture_path, "config", "missing.yml"))
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["_APPSIGNAL_ACTIVE"]).to eq "true"
616
- expect(ENV["_APPSIGNAL_APP_PATH"]).to end_with("spec/support/fixtures/projects/valid")
617
- expect(ENV["_APPSIGNAL_AGENT_PATH"]).to end_with("/ext")
618
- expect(ENV["_APPSIGNAL_DEBUG_LOGGING"]).to eq "false"
619
- expect(ENV["_APPSIGNAL_LOG"]).to eq "stdout"
620
- expect(ENV["_APPSIGNAL_LOG_FILE_PATH"]).to end_with("/tmp/appsignal.log")
621
- expect(ENV["_APPSIGNAL_LOGGING_ENDPOINT"]).to eq "http://localhost:123"
622
- expect(ENV["_APPSIGNAL_PUSH_API_ENDPOINT"]).to eq "https://push.appsignal.com"
623
- expect(ENV["_APPSIGNAL_PUSH_API_KEY"]).to eq "abc"
624
- expect(ENV["_APPSIGNAL_APP_NAME"]).to eq "TestApp"
625
- expect(ENV["_APPSIGNAL_ENVIRONMENT"]).to eq "production"
626
- expect(ENV["_APPSIGNAL_LANGUAGE_INTEGRATION_VERSION"]).to eq "ruby-#{Appsignal::VERSION}"
627
- expect(ENV["_APPSIGNAL_HTTP_PROXY"]).to eq "http://localhost"
628
- expect(ENV["_APPSIGNAL_IGNORE_ACTIONS"]).to eq "action1,action2"
629
- expect(ENV["_APPSIGNAL_IGNORE_ERRORS"]).to eq "ExampleStandardError,AnotherError"
630
- expect(ENV["_APPSIGNAL_IGNORE_NAMESPACES"]).to eq "admin,private_namespace"
631
- expect(ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"]).to eq "false"
632
- expect(ENV["_APPSIGNAL_ENABLE_HOST_METRICS"]).to eq "true"
633
- expect(ENV["_APPSIGNAL_HOSTNAME"]).to eq ""
634
- expect(ENV["_APPSIGNAL_PROCESS_NAME"]).to include "rspec"
635
- expect(ENV["_APPSIGNAL_CA_FILE_PATH"]).to eq File.join(resources_dir, "cacert.pem")
636
- expect(ENV["_APPSIGNAL_DNS_SERVERS"]).to eq "8.8.8.8,8.8.4.4"
637
- expect(ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"]).to eq "true"
638
- expect(ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"]).to eq "true"
639
- expect(ENV["_APPSIGNAL_SEND_ENVIRONMENT_METADATA"]).to eq "false"
640
- expect(ENV["_APPSIGNAL_FILTER_PARAMETERS"]).to eq "password,confirm_password"
641
- expect(ENV["_APPSIGNAL_FILTER_SESSION_DATA"]).to eq "key1,key2"
642
- expect(ENV["_APP_REVISION"]).to eq "v2.5.1"
643
- expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
644
- expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIRECTORY_PATH")
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["_APPSIGNAL_HOSTNAME"]).to eq "Alices-MBP.example.com"
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["_APPSIGNAL_WORKING_DIR_PATH"]).to eq "/tmp/appsignal2"
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["_APPSIGNAL_WORKING_DIRECTORY_PATH"]).to eq "/tmp/appsignal2"
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", klass)).to be_truthy
13
- expect(Appsignal::EventFormatter.registered?("render_template.action_view", klass)).to be_truthy
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) { { :identifier => "/var/www/app/20130101/app/views/home/index/html.erb".freeze } }
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", klass)).to be_falsy
50
- expect(Appsignal::EventFormatter.registered?("render_template.action_view", klass)).to be_falsy
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 => "Search",
15
- :klass => "User",
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 => "user",
33
- :q => "John Doe",
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" => "users",
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
- "when initializing mock.dependent event formatter"
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
- "method' when initializing mock.missing event formatter"
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
- "method' when initializing mock.incorrect event formatter"
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
- "method' when initializing mock.incorrect event formatter"
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
- .with(transaction_id, Appsignal::Transaction::ACTION_CABLE, kind_of(ActionDispatch::Request))
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", :content_type => "text/html") do |format|
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 an ActiveSupport::Notifications.start/finish event with payload on start ignores payload" do
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, :status => :processed))
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, :status => :processed))
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, :status => :failed))
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", :skip => DependencyHelper.rails_version < Gem::Version.new("5.0.0") do
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", :skip => DependencyHelper.rails_version < Gem::Version.new("6.0.0") do
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", "deliver_now"] + active_job_args_wrapper,
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", "deliver_now"] + active_job_args_wrapper(:args => method_expected_args),
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" => ["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper(:params => parameterized_expected_args),
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) do
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)
@@ -3,6 +3,7 @@ describe Appsignal::Hooks::DataMapperHook do
3
3
  before :context do
4
4
  module DataMapper
5
5
  end
6
+
6
7
  module DataObjects
7
8
  class Connection
8
9
  end
@@ -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 => 123,
43
- :name => "TestClass#perform",
44
- :priority => 1,
45
- :attempts => 1,
46
- :queue => "default",
47
- :created_at => created_at,
48
- :run_at => 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" => "default",
80
- "id" => "123"
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 being acting like a Hash and returning a non-String value" do
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" => "default",
283
- "id" => "123"
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 { allow(Appsignal::Hooks::MongoMonitorSubscriber).to receive(:new).and_return(subscriber) }
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 => { "SentTimestamp" => (Time.parse("1976-11-18 01:00:00UTC").to_i * 1000).to_s }
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
@@ -21,7 +21,8 @@ describe Appsignal::Hooks::SidekiqHook do
21
21
  alias exists? include?
22
22
 
23
23
  unless method_defined? :prepend
24
- def prepend(middleware) # For Ruby < 2.5
24
+ # For Ruby < 2.5
25
+ def prepend(middleware)
25
26
  insert(0, middleware)
26
27
  end
27
28
  end
@@ -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).with("Error while installing mock_error_hook hook: error").once
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("../../../../", __FILE__))
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
- "Please update the constant name to Appsignal::Integrations::SidekiqMiddleware " \
108
- "in the following file to remove this message.\n#{__FILE__}:"
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