appsignal 3.12.6-java → 4.0.0.beta.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +499 -487
  3. data/CHANGELOG.md +151 -0
  4. data/Rakefile +31 -7
  5. data/benchmark.rake +4 -6
  6. data/build_matrix.yml +45 -39
  7. data/ext/agent.rb +27 -27
  8. data/ext/appsignal_extension.c +25 -0
  9. data/gemfiles/rails-7.2.gemfile +11 -0
  10. data/lib/appsignal/check_in/cron.rb +67 -0
  11. data/lib/appsignal/check_in.rb +46 -0
  12. data/lib/appsignal/cli/diagnose.rb +37 -28
  13. data/lib/appsignal/cli/install.rb +5 -1
  14. data/lib/appsignal/config.rb +57 -119
  15. data/lib/appsignal/demo.rb +2 -2
  16. data/lib/appsignal/extension/jruby.rb +14 -0
  17. data/lib/appsignal/helpers/instrumentation.rb +139 -414
  18. data/lib/appsignal/helpers/metrics.rb +0 -16
  19. data/lib/appsignal/hooks/action_cable.rb +8 -8
  20. data/lib/appsignal/hooks/active_job.rb +2 -2
  21. data/lib/appsignal/hooks/at_exit.rb +37 -0
  22. data/lib/appsignal/hooks.rb +1 -16
  23. data/lib/appsignal/integrations/action_cable.rb +2 -2
  24. data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
  25. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
  26. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
  27. data/lib/appsignal/integrations/http.rb +2 -7
  28. data/lib/appsignal/integrations/que.rb +2 -2
  29. data/lib/appsignal/integrations/railtie.rb +26 -59
  30. data/lib/appsignal/integrations/rake.rb +2 -2
  31. data/lib/appsignal/integrations/resque.rb +2 -2
  32. data/lib/appsignal/integrations/shoryuken.rb +4 -4
  33. data/lib/appsignal/integrations/sidekiq.rb +3 -3
  34. data/lib/appsignal/integrations/webmachine.rb +2 -2
  35. data/lib/appsignal/loaders.rb +1 -1
  36. data/lib/appsignal/probes.rb +0 -9
  37. data/lib/appsignal/rack/abstract_middleware.rb +4 -26
  38. data/lib/appsignal/rack/event_handler.rb +4 -4
  39. data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
  40. data/lib/appsignal/rack.rb +0 -25
  41. data/lib/appsignal/sample_data.rb +95 -0
  42. data/lib/appsignal/transaction.rb +235 -361
  43. data/lib/appsignal/utils/rails_helper.rb +4 -0
  44. data/lib/appsignal/version.rb +1 -1
  45. data/lib/appsignal.rb +20 -62
  46. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  47. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  48. data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
  49. data/spec/lib/appsignal/{heartbeat_spec.rb → check_in_spec.rb} +45 -36
  50. data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
  51. data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
  52. data/spec/lib/appsignal/config_spec.rb +304 -379
  53. data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
  54. data/spec/lib/appsignal/extension_spec.rb +5 -1
  55. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  56. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
  57. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
  58. data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
  59. data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
  60. data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
  61. data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
  62. data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
  63. data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
  64. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
  65. data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
  66. data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
  67. data/spec/lib/appsignal/hooks_spec.rb +0 -41
  68. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
  69. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
  70. data/spec/lib/appsignal/integrations/http_spec.rb +0 -21
  71. data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
  72. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
  73. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
  74. data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
  75. data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
  76. data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
  77. data/spec/lib/appsignal/loaders_spec.rb +8 -1
  78. data/spec/lib/appsignal/marker_spec.rb +1 -1
  79. data/spec/lib/appsignal/probes_spec.rb +4 -83
  80. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
  81. data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
  82. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
  83. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
  84. data/spec/lib/appsignal/sample_data_spec.rb +174 -0
  85. data/spec/lib/appsignal/transaction_spec.rb +791 -1031
  86. data/spec/lib/appsignal/transmitter_spec.rb +6 -8
  87. data/spec/lib/appsignal_spec.rb +294 -643
  88. data/spec/spec_helper.rb +1 -3
  89. data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
  90. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
  91. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
  92. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
  93. data/spec/support/helpers/api_request_helper.rb +3 -2
  94. data/spec/support/helpers/config_helpers.rb +41 -11
  95. data/spec/support/helpers/dependency_helper.rb +8 -0
  96. data/spec/support/helpers/log_helpers.rb +1 -0
  97. data/spec/support/helpers/rails_helper.rb +6 -6
  98. data/spec/support/helpers/transaction_helpers.rb +2 -24
  99. data/spec/support/matchers/transaction.rb +3 -3
  100. data/spec/support/mocks/appsignal_mock.rb +3 -3
  101. data/spec/support/mocks/mock_probe.rb +2 -0
  102. data/spec/support/testing.rb +2 -2
  103. metadata +14 -23
  104. data/gemfiles/que_beta.gemfile +0 -5
  105. data/lib/appsignal/heartbeat.rb +0 -59
  106. data/lib/appsignal/helpers/heartbeats.rb +0 -44
  107. data/lib/appsignal/integrations/grape.rb +0 -35
  108. data/lib/appsignal/integrations/hanami.rb +0 -13
  109. data/lib/appsignal/integrations/padrino.rb +0 -13
  110. data/lib/appsignal/integrations/sinatra.rb +0 -13
  111. data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
  112. data/lib/appsignal/rack/streaming_listener.rb +0 -28
  113. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
  114. data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
  115. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
  116. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
  117. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
  118. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
  119. data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
  120. data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
  121. data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
  122. data/spec/support/rails/my_app.rb +0 -6
  123. /data/spec/support/fixtures/projects/{valid/config/application.rb → valid_with_rails_app/log/.gitkeep} +0 -0
@@ -24,9 +24,22 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
24
24
  describe ".run" do
25
25
  let(:out_stream) { std_stream }
26
26
  let(:output) { out_stream.read }
27
- let(:config) { project_fixture_config }
27
+ let(:root_path) { project_fixture_path }
28
+ let(:app_name) { "TestApp" }
29
+ let(:push_api_key) { "abc" }
30
+ let(:environment) { "production" }
31
+ let(:config) do
32
+ {
33
+ :root_path => root_path,
34
+ :environment => environment.to_s,
35
+ :name => app_name,
36
+ :endpoint => Appsignal::Config::DEFAULT_CONFIG[:endpoint],
37
+ :push_api_key => push_api_key,
38
+ :hostname => nil
39
+ }
40
+ end
28
41
  let(:cli_class) { described_class }
29
- let(:options) { { :environment => config.env } }
42
+ let(:options) { { :environment => environment } }
30
43
  let(:gem_path) { Bundler::CLI::Common.select_spec("appsignal").full_gem_path.strip }
31
44
  let(:received_report) { DiagnosticsReportEndpoint.received_report }
32
45
  let(:process_user) { Etc.getpwuid(Process.uid).name }
@@ -43,7 +56,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
43
56
  end
44
57
 
45
58
  if DependencyHelper.rails_present?
46
- allow(Rails).to receive(:root).and_return(Pathname.new(config.root_path))
59
+ allow(Rails).to receive(:root).and_return(Pathname.new(config[:root_path]))
47
60
  end
48
61
  end
49
62
  around do |example|
@@ -52,6 +65,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
52
65
  example.run
53
66
  $stdin = original_stdin
54
67
  end
68
+ before { clear_integration_env_vars! }
55
69
  before :api_stub => true do
56
70
  stub_api_request config, "auth"
57
71
  end
@@ -87,7 +101,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
87
101
  stub_request(:post, "https://appsignal.com/diag").with(
88
102
  :query => {
89
103
  :api_key => config[:push_api_key],
90
- :environment => config.env,
104
+ :environment => config[:environment],
91
105
  :gem_version => Appsignal::VERSION,
92
106
  :hostname => config[:hostname],
93
107
  :name => config[:name]
@@ -114,7 +128,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
114
128
 
115
129
  it "logs to the log file" do
116
130
  run
117
- log_contents = File.read(config.log_file_path)
131
+ log_contents = File.read(Appsignal.config.log_file_path)
118
132
  expect(log_contents).to contains_log :info, "Starting AppSignal diagnose"
119
133
  end
120
134
 
@@ -741,7 +755,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
741
755
 
742
756
  describe "configuration" do
743
757
  context "without environment" do
744
- let(:config) { project_fixture_config(nil) }
758
+ let(:app_name) { nil }
759
+ let(:environment) { nil }
760
+ let(:push_api_key) { nil }
745
761
  let(:options) { {} }
746
762
  let(:warning_message) do
747
763
  " Warning: No environment set, no config loaded!\n" \
@@ -779,13 +795,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
779
795
  "sources" => {
780
796
  "default" => default_config,
781
797
  "system" => {},
798
+ "loaders" => {},
782
799
  "initial" => { "env" => "" },
783
800
  "file" => {},
784
801
  "env" => {},
785
- "override" => { "send_session_data" => true }
786
- },
787
- "modifiers" => {
788
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
802
+ "override" => {},
803
+ "dsl" => {}
789
804
  }
790
805
  )
791
806
  end
@@ -803,13 +818,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
803
818
 
804
819
  it "outputs the label source after the value" do
805
820
  expect(output).to include(
806
- %(environment: "#{Appsignal.config.env}" (Loaded from: initial)\n)
821
+ %(environment: "#{environment}" (Loaded from: initial)\n)
807
822
  )
808
823
  end
809
824
  end
810
825
 
811
826
  context "when the source is the RACK_ENV env variable", :send_report => :no_cli_option do
812
- let(:config) { project_fixture_config("rack_env") }
827
+ let(:environment) { "rack_env" }
813
828
  let(:options) { {} }
814
829
  before do
815
830
  ENV["RACK_ENV"] = "rack_env"
@@ -825,10 +840,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
825
840
  end
826
841
 
827
842
  context "when the source is the RAILS_ENV env variable", :send_report => :no_cli_option do
828
- let(:config) { project_fixture_config("rails_env") }
843
+ let(:environment) { "rails_env" }
829
844
  let(:options) { {} }
830
845
  before do
831
- ENV.delete("RACK_ENV")
832
846
  ENV["RAILS_ENV"] = "rails_env"
833
847
  run
834
848
  end
@@ -842,10 +856,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
842
856
  end
843
857
 
844
858
  context "when the source is multiple sources" do
845
- let(:options) { { :environment => "development" } }
859
+ let(:options) { { :environment => "production" } }
846
860
  before do
847
- ENV["APPSIGNAL_APP_ENV"] = "production"
848
- config.instance_variable_set(:@env, ENV.fetch("APPSIGNAL_APP_ENV", nil))
861
+ ENV["APPSIGNAL_APP_ENV"] = "development"
849
862
  stub_api_request(config, "auth").to_return(:status => 200)
850
863
  capture_diagnatics_report_request
851
864
  run
@@ -855,8 +868,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
855
868
  expect(output).to include(
856
869
  " environment: \"production\"\n" \
857
870
  " Sources:\n" \
858
- " initial: \"development\"\n" \
859
- " env: \"production\"\n"
871
+ " initial: \"production\"\n" \
872
+ " env: \"development\"\n"
860
873
  )
861
874
  end
862
875
  end
@@ -880,98 +893,109 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
880
893
 
881
894
  context "when the source is only default" do
882
895
  it "does not print a source" do
883
- expect(output).to include("debug: #{Appsignal.config[:debug]}\n")
896
+ expect(output)
897
+ .to include("enable_host_metrics: #{Appsignal.config[:enable_host_metrics]}\n")
884
898
  end
885
899
  end
886
900
  end
887
901
 
888
902
  context "when the source is multiple sources" do
903
+ let(:app_name) { "MyApp" }
889
904
  before do
890
- ENV["APPSIGNAL_APP_NAME"] = "MyApp"
891
- config[:name] = ENV.fetch("APPSIGNAL_APP_NAME", nil)
892
- stub_api_request(config, "auth").to_return(:status => 200)
893
- capture_diagnatics_report_request
905
+ ENV["APPSIGNAL_APP_NAME"] = app_name
894
906
  run
895
907
  end
896
908
 
897
- if DependencyHelper.rails_present?
898
- it "outputs a list of sources with their values" do
899
- expect(output).to include(
900
- " name: \"MyApp\"\n" \
901
- " Sources:\n" \
902
- " initial: \"MyApp\"\n" \
903
- " file: \"TestApp\"\n" \
904
- " env: \"MyApp\"\n"
905
- )
909
+ it "outputs a list of sources with their values" do
910
+ expect(output).to include(
911
+ " name: \"MyApp\"\n" \
912
+ " Sources:\n" \
913
+ " file: \"TestApp\"\n" \
914
+ " env: \"MyApp\"\n"
915
+ )
916
+ end
917
+ end
918
+
919
+ if DependencyHelper.rails_present?
920
+ context "when is a Rails app" do
921
+ let(:root_path) { rails_project_fixture_path }
922
+ let(:app_name) { "TestApp" }
923
+ let(:environment) { "test" }
924
+ let(:options) { {} }
925
+ before do
926
+ # Workaround to not being able to require the railtie file
927
+ # multiple times and triggering the Rails initialization process.
928
+ # This will be used whtn the MyApp app has already been loaded.
929
+ Appsignal::Integrations::Railtie.load_default_config if defined?(MyApp)
930
+ run_within_dir(root_path)
906
931
  end
907
- else
908
- it "outputs a list of sources with their values" do
932
+
933
+ it "includes the Rails default config in the output and transmitted report" do
909
934
  expect(output).to include(
910
- " name: \"MyApp\"\n" \
935
+ " name: \"TestApp\"\n" \
911
936
  " Sources:\n" \
912
- " file: \"TestApp\"\n" \
913
- " env: \"MyApp\"\n"
937
+ " loaders: \"MyApp\"\n" \
938
+ " file: \"TestApp\"\n"
914
939
  )
915
- end
916
- end
917
- end
918
- end
919
-
920
- describe "modifiers" do
921
- before do
922
- ENV["APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR"] = "1"
923
- run
924
- end
925
940
 
926
- it "outputs config modifiers" do
927
- expect(output).to include(
928
- "Configuration modifiers\n" \
929
- " APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR: \"1\""
930
- )
931
- end
941
+ expect(received_report["app"]["rails"]).to be(true)
942
+ expect(received_report["config"]["sources"]).to include(
943
+ "loaders" => {
944
+ "root_path" => root_path,
945
+ "env" => "test",
946
+ "log_path" => File.join(rails_project_fixture_path, "log"),
947
+ "name" => "MyApp"
948
+ }
949
+ )
950
+ end
932
951
 
933
- it "transmits config modifiers in report" do
934
- expect(received_report["config"]).to include(
935
- "modifiers" => {
936
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => "1"
937
- }
938
- )
952
+ context "when there's a problem loading the app" do
953
+ before do
954
+ # A spot where we can mock an error raise
955
+ expect(Appsignal::Utils::RailsHelper).to receive(:environment_config_path)
956
+ .and_raise(ExampleStandardError, "error message", ["line 1", "line 2"])
957
+ run_within_dir(root_path)
958
+ end
959
+
960
+ it "includes a load error" do
961
+ expect(output).to include(
962
+ "ERROR: Error encountered while loading the Rails app\n" \
963
+ "ExampleStandardError: error message"
964
+ )
965
+
966
+ pp received_report["app"]
967
+ expect(received_report["app"]["load_error"])
968
+ .to eq("ExampleStandardError: error message\nline 1\nline 2")
969
+ end
970
+ end
971
+ end
939
972
  end
940
973
  end
941
974
 
942
975
  it "transmits config in report" do
943
976
  run
944
- additional_initial_config = {}
945
- if DependencyHelper.rails_present?
946
- additional_initial_config = {
947
- :name => "MyApp",
948
- :log_path => File.join(Rails.root, "log")
949
- }
950
- end
951
- final_config = { "env" => "production" }
952
- .merge(additional_initial_config)
953
- .merge(config.config_hash)
977
+ final_config = Appsignal.config.config_hash
978
+ .merge(:env => "production")
954
979
  expect(received_report["config"]).to match(
955
980
  "options" => hash_with_string_keys(final_config),
956
981
  "sources" => {
957
982
  "default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
958
983
  "system" => {},
959
- "initial" => hash_with_string_keys(
960
- config.initial_config.merge(additional_initial_config)
961
- ),
962
- "file" => hash_with_string_keys(config.file_config),
984
+ "loaders" => {},
985
+ "initial" => hash_with_string_keys(Appsignal.config.initial_config),
986
+ "file" => hash_with_string_keys(Appsignal.config.file_config),
963
987
  "env" => {},
964
- "override" => { "send_session_data" => true }
965
- },
966
- "modifiers" => {
967
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
988
+ "override" => {},
989
+ "dsl" => {}
968
990
  }
969
991
  )
970
992
  end
971
993
  end
972
994
 
973
995
  context "with unconfigured environment" do
974
- let(:config) { project_fixture_config("foobar") }
996
+ let(:app_name) { nil }
997
+ let(:push_api_key) { nil }
998
+ let(:environment) { "foobar" }
975
999
  before { run_within_dir tmp_dir }
976
1000
 
977
1001
  it "outputs environment" do
@@ -985,17 +1009,18 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
985
1009
 
986
1010
  it "transmits config in report" do
987
1011
  expect(received_report["config"]).to match(
988
- "options" => hash_with_string_keys(config.config_hash).merge("env" => "foobar"),
1012
+ "options" => hash_with_string_keys(
1013
+ Appsignal.config.config_hash.merge("env" => "foobar")
1014
+ ),
989
1015
  "sources" => {
990
1016
  "default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
991
1017
  "system" => {},
992
- "initial" => hash_with_string_keys(config.initial_config),
993
- "file" => hash_with_string_keys(config.file_config),
1018
+ "loaders" => {},
1019
+ "initial" => hash_with_string_keys(Appsignal.config.initial_config),
1020
+ "file" => hash_with_string_keys(Appsignal.config.file_config),
994
1021
  "env" => {},
995
- "override" => { "send_session_data" => true }
996
- },
997
- "modifiers" => {
998
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
1022
+ "override" => {},
1023
+ "dsl" => {}
999
1024
  }
1000
1025
  )
1001
1026
  end
@@ -1108,18 +1133,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1108
1133
  end
1109
1134
 
1110
1135
  describe "paths" do
1111
- let(:config) { Appsignal::Config.new(root_path, "production") }
1112
- let(:root_path) { tmp_dir }
1113
- let(:system_tmp_dir) { Appsignal::Config.system_tmp_dir }
1114
- before do
1115
- FileUtils.mkdir_p(root_path)
1116
- FileUtils.mkdir_p(system_tmp_dir)
1117
- end
1118
- after { FileUtils.rm_rf([root_path, system_tmp_dir]) }
1119
-
1120
1136
  describe "report" do
1121
1137
  it "adds paths to the report" do
1122
- run_within_dir root_path
1138
+ run
1123
1139
  expect(received_report["paths"].keys).to match_array(
1124
1140
  %w[
1125
1141
  package_install_path root_path working_dir log_dir_path
@@ -1129,15 +1145,15 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1129
1145
  end
1130
1146
 
1131
1147
  describe "working_dir" do
1132
- before { run_within_dir root_path }
1148
+ before { run }
1133
1149
 
1134
1150
  it "outputs current path" do
1135
- expect(output).to include %(Current working directory\n Path: "#{tmp_dir}")
1151
+ expect(output).to include %(Current working directory\n Path: "#{root_path}")
1136
1152
  end
1137
1153
 
1138
1154
  it "transmits path data in report" do
1139
1155
  expect(received_report["paths"]["working_dir"]).to match(
1140
- "path" => tmp_dir,
1156
+ "path" => root_path,
1141
1157
  "exists" => true,
1142
1158
  "type" => "directory",
1143
1159
  "mode" => kind_of(String),
@@ -1153,7 +1169,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1153
1169
  end
1154
1170
 
1155
1171
  describe "root_path" do
1156
- before { run_within_dir root_path }
1172
+ before { run }
1157
1173
 
1158
1174
  it "outputs root path" do
1159
1175
  expect(output).to include %(Root path\n Path: "#{root_path}")
@@ -1177,7 +1193,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1177
1193
  end
1178
1194
 
1179
1195
  describe "package_install_path" do
1180
- before { run_within_dir root_path }
1196
+ before { run }
1181
1197
 
1182
1198
  it "outputs gem install path" do
1183
1199
  expect(output).to match %(AppSignal gem path\n Path: "#{gem_path}")
@@ -1201,15 +1217,16 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1201
1217
  end
1202
1218
 
1203
1219
  describe "log_dir_path" do
1204
- before { run_within_dir root_path }
1220
+ let(:log_path) { File.dirname(Appsignal.config.log_file_path) }
1221
+ before { run }
1205
1222
 
1206
1223
  it "outputs log directory path" do
1207
- expect(output).to match %(Log directory\n Path: "#{system_tmp_dir}")
1224
+ expect(output).to match %(Log directory\n Path: "#{log_path}")
1208
1225
  end
1209
1226
 
1210
1227
  it "transmits path data in report" do
1211
1228
  expect(received_report["paths"]["log_dir_path"]).to match(
1212
- "path" => system_tmp_dir,
1229
+ "path" => log_path,
1213
1230
  "exists" => true,
1214
1231
  "type" => "directory",
1215
1232
  "mode" => kind_of(String),
@@ -1227,15 +1244,15 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1227
1244
 
1228
1245
  context "when a directory does not exist" do
1229
1246
  let(:root_path) { tmp_dir }
1247
+ let(:environment) { nil }
1248
+ let(:push_api_key) { nil }
1249
+ let(:app_name) { nil }
1250
+ let(:options) { {} }
1230
1251
  let(:execution_path) { File.join(tmp_dir, "not_existing_dir") }
1231
- let(:config) do
1232
- silence(:allowed => ["Push api key not set after loading config"]) do
1233
- Appsignal::Config.new(execution_path, "production")
1234
- end
1235
- end
1236
1252
  before do
1237
1253
  allow(Dir).to receive(:pwd).and_return(execution_path)
1238
- run_within_dir tmp_dir
1254
+ FileUtils.rm_rf(execution_path)
1255
+ run_within_dir root_path
1239
1256
  end
1240
1257
 
1241
1258
  it "outputs not existing path" do
@@ -1252,7 +1269,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1252
1269
 
1253
1270
  context "when not writable" do
1254
1271
  let(:root_path) { File.join(tmp_dir, "not_writable_path") }
1272
+ let(:environment) { nil }
1273
+ let(:push_api_key) { nil }
1274
+ let(:app_name) { nil }
1275
+ let(:options) { {} }
1255
1276
  before do
1277
+ FileUtils.mkdir_p(root_path)
1256
1278
  FileUtils.chmod(0o555, root_path)
1257
1279
  run_within_dir root_path
1258
1280
  end
@@ -1280,7 +1302,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1280
1302
 
1281
1303
  context "when writable" do
1282
1304
  let(:root_path) { File.join(tmp_dir, "writable_path") }
1305
+ let(:environment) { nil }
1306
+ let(:push_api_key) { nil }
1307
+ let(:app_name) { nil }
1308
+ let(:options) { {} }
1283
1309
  before do
1310
+ FileUtils.mkdir_p(root_path)
1284
1311
  FileUtils.chmod(0o755, root_path)
1285
1312
  run_within_dir root_path
1286
1313
  end
@@ -1307,6 +1334,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1307
1334
  end
1308
1335
 
1309
1336
  describe "ownership" do
1337
+ let(:environment) { nil }
1338
+ let(:push_api_key) { nil }
1339
+ let(:app_name) { nil }
1340
+ let(:options) { {} }
1341
+ before do
1342
+ FileUtils.mkdir_p(root_path)
1343
+ end
1344
+
1310
1345
  context "when a directory is owned by the current user" do
1311
1346
  let(:root_path) { File.join(tmp_dir, "owned_path") }
1312
1347
  before { run_within_dir root_path }