appsignal 3.13.2-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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +499 -488
  3. data/CHANGELOG.md +98 -15
  4. data/Rakefile +31 -7
  5. data/benchmark.rake +4 -6
  6. data/build_matrix.yml +46 -40
  7. data/ext/agent.rb +30 -30
  8. data/ext/appsignal_extension.c +25 -0
  9. data/gemfiles/grape.gemfile +1 -5
  10. data/gemfiles/rails-6.0.gemfile +0 -4
  11. data/gemfiles/rails-6.1.gemfile +0 -4
  12. data/gemfiles/rails-7.1.gemfile +1 -6
  13. data/gemfiles/rails-7.2.gemfile +11 -0
  14. data/lib/appsignal/check_in/cron.rb +2 -15
  15. data/lib/appsignal/cli/diagnose.rb +37 -28
  16. data/lib/appsignal/cli/install.rb +5 -1
  17. data/lib/appsignal/config.rb +57 -119
  18. data/lib/appsignal/demo.rb +2 -2
  19. data/lib/appsignal/extension/jruby.rb +14 -0
  20. data/lib/appsignal/helpers/instrumentation.rb +139 -417
  21. data/lib/appsignal/helpers/metrics.rb +0 -16
  22. data/lib/appsignal/hooks/action_cable.rb +8 -8
  23. data/lib/appsignal/hooks/active_job.rb +2 -2
  24. data/lib/appsignal/hooks/at_exit.rb +37 -0
  25. data/lib/appsignal/hooks.rb +1 -16
  26. data/lib/appsignal/integrations/action_cable.rb +2 -2
  27. data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
  28. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
  29. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
  30. data/lib/appsignal/integrations/que.rb +2 -2
  31. data/lib/appsignal/integrations/railtie.rb +26 -59
  32. data/lib/appsignal/integrations/rake.rb +2 -2
  33. data/lib/appsignal/integrations/resque.rb +2 -2
  34. data/lib/appsignal/integrations/shoryuken.rb +4 -4
  35. data/lib/appsignal/integrations/sidekiq.rb +3 -3
  36. data/lib/appsignal/integrations/webmachine.rb +2 -2
  37. data/lib/appsignal/loaders.rb +1 -1
  38. data/lib/appsignal/probes.rb +0 -9
  39. data/lib/appsignal/rack/abstract_middleware.rb +4 -26
  40. data/lib/appsignal/rack/body_wrapper.rb +0 -12
  41. data/lib/appsignal/rack/event_handler.rb +4 -4
  42. data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
  43. data/lib/appsignal/rack.rb +0 -25
  44. data/lib/appsignal/sample_data.rb +95 -0
  45. data/lib/appsignal/transaction.rb +235 -361
  46. data/lib/appsignal/utils/rails_helper.rb +4 -0
  47. data/lib/appsignal/version.rb +1 -1
  48. data/lib/appsignal.rb +19 -71
  49. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  50. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  51. data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
  52. data/spec/lib/appsignal/check_in_spec.rb +1 -207
  53. data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
  54. data/spec/lib/appsignal/cli/diagnose_spec.rb +148 -121
  55. data/spec/lib/appsignal/config_spec.rb +304 -379
  56. data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
  57. data/spec/lib/appsignal/extension_spec.rb +5 -1
  58. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  59. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
  60. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
  61. data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
  62. data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
  63. data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
  64. data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
  65. data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
  66. data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
  67. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
  68. data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
  69. data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
  70. data/spec/lib/appsignal/hooks_spec.rb +0 -41
  71. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
  72. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
  73. data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
  74. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
  75. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
  76. data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
  77. data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
  78. data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
  79. data/spec/lib/appsignal/loaders_spec.rb +8 -1
  80. data/spec/lib/appsignal/marker_spec.rb +1 -1
  81. data/spec/lib/appsignal/probes_spec.rb +4 -83
  82. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
  83. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -48
  84. data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
  85. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
  86. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
  87. data/spec/lib/appsignal/sample_data_spec.rb +174 -0
  88. data/spec/lib/appsignal/transaction_spec.rb +791 -1031
  89. data/spec/lib/appsignal/transmitter_spec.rb +6 -8
  90. data/spec/lib/appsignal_spec.rb +294 -643
  91. data/spec/spec_helper.rb +1 -3
  92. data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
  93. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
  94. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
  95. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
  96. data/spec/support/helpers/api_request_helper.rb +3 -2
  97. data/spec/support/helpers/config_helpers.rb +40 -10
  98. data/spec/support/helpers/dependency_helper.rb +8 -0
  99. data/spec/support/helpers/log_helpers.rb +1 -0
  100. data/spec/support/helpers/rails_helper.rb +6 -6
  101. data/spec/support/helpers/transaction_helpers.rb +2 -24
  102. data/spec/support/matchers/transaction.rb +3 -3
  103. data/spec/support/mocks/appsignal_mock.rb +3 -3
  104. data/spec/support/mocks/mock_probe.rb +2 -0
  105. data/spec/support/testing.rb +2 -2
  106. metadata +15 -22
  107. data/gemfiles/que_beta.gemfile +0 -5
  108. data/lib/appsignal/helpers/heartbeat.rb +0 -20
  109. data/lib/appsignal/integrations/grape.rb +0 -35
  110. data/lib/appsignal/integrations/hanami.rb +0 -13
  111. data/lib/appsignal/integrations/padrino.rb +0 -13
  112. data/lib/appsignal/integrations/sinatra.rb +0 -13
  113. data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
  114. data/lib/appsignal/rack/streaming_listener.rb +0 -28
  115. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
  116. data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
  117. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
  118. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
  119. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
  120. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
  121. data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
  122. data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
  123. data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
  124. data/spec/support/rails/my_app.rb +0 -6
  125. /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
 
@@ -466,15 +480,6 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
466
480
  end
467
481
 
468
482
  context "when the extension returns invalid JSON" do
469
- # The JSON gem reworded this error in version 2.10. Accept the wording
470
- # from before that release and the wording from after it.
471
- let(:parse_error) do
472
- Regexp.union(
473
- "unexpected token at 'invalid agent\njson'",
474
- "unexpected character: 'invalid' at line 1 column 1"
475
- )
476
- end
477
-
478
483
  before do
479
484
  expect(Appsignal::Extension).to receive(:diagnose).and_return("invalid agent\njson")
480
485
  run
@@ -485,11 +490,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
485
490
  "Agent diagnostics",
486
491
  " Error while parsing agent diagnostics report:",
487
492
  " Output: invalid agent\njson"
488
- expect(output).to match(/Error:( \d+:)? #{parse_error}/)
493
+ expect(output).to match(/Error:( \d+:)? unexpected token at 'invalid agent\njson'/)
489
494
  end
490
495
 
491
496
  it "adds the output to the report" do
492
- expect(received_report["agent"]["error"]).to match(parse_error)
497
+ expect(received_report["agent"]["error"])
498
+ .to match(/unexpected token at 'invalid agent\njson'/)
493
499
  expect(received_report["agent"]["output"]).to eq(["invalid agent", "json"])
494
500
  end
495
501
  end
@@ -749,7 +755,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
749
755
 
750
756
  describe "configuration" do
751
757
  context "without environment" do
752
- let(:config) { project_fixture_config(nil) }
758
+ let(:app_name) { nil }
759
+ let(:environment) { nil }
760
+ let(:push_api_key) { nil }
753
761
  let(:options) { {} }
754
762
  let(:warning_message) do
755
763
  " Warning: No environment set, no config loaded!\n" \
@@ -787,13 +795,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
787
795
  "sources" => {
788
796
  "default" => default_config,
789
797
  "system" => {},
798
+ "loaders" => {},
790
799
  "initial" => { "env" => "" },
791
800
  "file" => {},
792
801
  "env" => {},
793
- "override" => { "send_session_data" => true }
794
- },
795
- "modifiers" => {
796
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
802
+ "override" => {},
803
+ "dsl" => {}
797
804
  }
798
805
  )
799
806
  end
@@ -811,13 +818,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
811
818
 
812
819
  it "outputs the label source after the value" do
813
820
  expect(output).to include(
814
- %(environment: "#{Appsignal.config.env}" (Loaded from: initial)\n)
821
+ %(environment: "#{environment}" (Loaded from: initial)\n)
815
822
  )
816
823
  end
817
824
  end
818
825
 
819
826
  context "when the source is the RACK_ENV env variable", :send_report => :no_cli_option do
820
- let(:config) { project_fixture_config("rack_env") }
827
+ let(:environment) { "rack_env" }
821
828
  let(:options) { {} }
822
829
  before do
823
830
  ENV["RACK_ENV"] = "rack_env"
@@ -833,10 +840,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
833
840
  end
834
841
 
835
842
  context "when the source is the RAILS_ENV env variable", :send_report => :no_cli_option do
836
- let(:config) { project_fixture_config("rails_env") }
843
+ let(:environment) { "rails_env" }
837
844
  let(:options) { {} }
838
845
  before do
839
- ENV.delete("RACK_ENV")
840
846
  ENV["RAILS_ENV"] = "rails_env"
841
847
  run
842
848
  end
@@ -850,10 +856,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
850
856
  end
851
857
 
852
858
  context "when the source is multiple sources" do
853
- let(:options) { { :environment => "development" } }
859
+ let(:options) { { :environment => "production" } }
854
860
  before do
855
- ENV["APPSIGNAL_APP_ENV"] = "production"
856
- config.instance_variable_set(:@env, ENV.fetch("APPSIGNAL_APP_ENV", nil))
861
+ ENV["APPSIGNAL_APP_ENV"] = "development"
857
862
  stub_api_request(config, "auth").to_return(:status => 200)
858
863
  capture_diagnatics_report_request
859
864
  run
@@ -863,8 +868,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
863
868
  expect(output).to include(
864
869
  " environment: \"production\"\n" \
865
870
  " Sources:\n" \
866
- " initial: \"development\"\n" \
867
- " env: \"production\"\n"
871
+ " initial: \"production\"\n" \
872
+ " env: \"development\"\n"
868
873
  )
869
874
  end
870
875
  end
@@ -888,98 +893,109 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
888
893
 
889
894
  context "when the source is only default" do
890
895
  it "does not print a source" do
891
- expect(output).to include("debug: #{Appsignal.config[:debug]}\n")
896
+ expect(output)
897
+ .to include("enable_host_metrics: #{Appsignal.config[:enable_host_metrics]}\n")
892
898
  end
893
899
  end
894
900
  end
895
901
 
896
902
  context "when the source is multiple sources" do
903
+ let(:app_name) { "MyApp" }
897
904
  before do
898
- ENV["APPSIGNAL_APP_NAME"] = "MyApp"
899
- config[:name] = ENV.fetch("APPSIGNAL_APP_NAME", nil)
900
- stub_api_request(config, "auth").to_return(:status => 200)
901
- capture_diagnatics_report_request
905
+ ENV["APPSIGNAL_APP_NAME"] = app_name
902
906
  run
903
907
  end
904
908
 
905
- if DependencyHelper.rails_present?
906
- it "outputs a list of sources with their values" do
907
- expect(output).to include(
908
- " name: \"MyApp\"\n" \
909
- " Sources:\n" \
910
- " initial: \"MyApp\"\n" \
911
- " file: \"TestApp\"\n" \
912
- " env: \"MyApp\"\n"
913
- )
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)
914
931
  end
915
- else
916
- 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
917
934
  expect(output).to include(
918
- " name: \"MyApp\"\n" \
935
+ " name: \"TestApp\"\n" \
919
936
  " Sources:\n" \
920
- " file: \"TestApp\"\n" \
921
- " env: \"MyApp\"\n"
937
+ " loaders: \"MyApp\"\n" \
938
+ " file: \"TestApp\"\n"
922
939
  )
923
- end
924
- end
925
- end
926
- end
927
-
928
- describe "modifiers" do
929
- before do
930
- ENV["APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR"] = "1"
931
- run
932
- end
933
940
 
934
- it "outputs config modifiers" do
935
- expect(output).to include(
936
- "Configuration modifiers\n" \
937
- " APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR: \"1\""
938
- )
939
- 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
940
951
 
941
- it "transmits config modifiers in report" do
942
- expect(received_report["config"]).to include(
943
- "modifiers" => {
944
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => "1"
945
- }
946
- )
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
947
972
  end
948
973
  end
949
974
 
950
975
  it "transmits config in report" do
951
976
  run
952
- additional_initial_config = {}
953
- if DependencyHelper.rails_present?
954
- additional_initial_config = {
955
- :name => "MyApp",
956
- :log_path => File.join(Rails.root, "log")
957
- }
958
- end
959
- final_config = { "env" => "production" }
960
- .merge(additional_initial_config)
961
- .merge(config.config_hash)
977
+ final_config = Appsignal.config.config_hash
978
+ .merge(:env => "production")
962
979
  expect(received_report["config"]).to match(
963
980
  "options" => hash_with_string_keys(final_config),
964
981
  "sources" => {
965
982
  "default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
966
983
  "system" => {},
967
- "initial" => hash_with_string_keys(
968
- config.initial_config.merge(additional_initial_config)
969
- ),
970
- "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),
971
987
  "env" => {},
972
- "override" => { "send_session_data" => true }
973
- },
974
- "modifiers" => {
975
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
988
+ "override" => {},
989
+ "dsl" => {}
976
990
  }
977
991
  )
978
992
  end
979
993
  end
980
994
 
981
995
  context "with unconfigured environment" do
982
- let(:config) { project_fixture_config("foobar") }
996
+ let(:app_name) { nil }
997
+ let(:push_api_key) { nil }
998
+ let(:environment) { "foobar" }
983
999
  before { run_within_dir tmp_dir }
984
1000
 
985
1001
  it "outputs environment" do
@@ -993,17 +1009,18 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
993
1009
 
994
1010
  it "transmits config in report" do
995
1011
  expect(received_report["config"]).to match(
996
- "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
+ ),
997
1015
  "sources" => {
998
1016
  "default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
999
1017
  "system" => {},
1000
- "initial" => hash_with_string_keys(config.initial_config),
1001
- "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),
1002
1021
  "env" => {},
1003
- "override" => { "send_session_data" => true }
1004
- },
1005
- "modifiers" => {
1006
- "APPSIGNAL_INACTIVE_ON_CONFIG_FILE_ERROR" => ""
1022
+ "override" => {},
1023
+ "dsl" => {}
1007
1024
  }
1008
1025
  )
1009
1026
  end
@@ -1116,18 +1133,9 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1116
1133
  end
1117
1134
 
1118
1135
  describe "paths" do
1119
- let(:config) { Appsignal::Config.new(root_path, "production") }
1120
- let(:root_path) { tmp_dir }
1121
- let(:system_tmp_dir) { Appsignal::Config.system_tmp_dir }
1122
- before do
1123
- FileUtils.mkdir_p(root_path)
1124
- FileUtils.mkdir_p(system_tmp_dir)
1125
- end
1126
- after { FileUtils.rm_rf([root_path, system_tmp_dir]) }
1127
-
1128
1136
  describe "report" do
1129
1137
  it "adds paths to the report" do
1130
- run_within_dir root_path
1138
+ run
1131
1139
  expect(received_report["paths"].keys).to match_array(
1132
1140
  %w[
1133
1141
  package_install_path root_path working_dir log_dir_path
@@ -1137,15 +1145,15 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1137
1145
  end
1138
1146
 
1139
1147
  describe "working_dir" do
1140
- before { run_within_dir root_path }
1148
+ before { run }
1141
1149
 
1142
1150
  it "outputs current path" do
1143
- expect(output).to include %(Current working directory\n Path: "#{tmp_dir}")
1151
+ expect(output).to include %(Current working directory\n Path: "#{root_path}")
1144
1152
  end
1145
1153
 
1146
1154
  it "transmits path data in report" do
1147
1155
  expect(received_report["paths"]["working_dir"]).to match(
1148
- "path" => tmp_dir,
1156
+ "path" => root_path,
1149
1157
  "exists" => true,
1150
1158
  "type" => "directory",
1151
1159
  "mode" => kind_of(String),
@@ -1161,7 +1169,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1161
1169
  end
1162
1170
 
1163
1171
  describe "root_path" do
1164
- before { run_within_dir root_path }
1172
+ before { run }
1165
1173
 
1166
1174
  it "outputs root path" do
1167
1175
  expect(output).to include %(Root path\n Path: "#{root_path}")
@@ -1185,7 +1193,7 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1185
1193
  end
1186
1194
 
1187
1195
  describe "package_install_path" do
1188
- before { run_within_dir root_path }
1196
+ before { run }
1189
1197
 
1190
1198
  it "outputs gem install path" do
1191
1199
  expect(output).to match %(AppSignal gem path\n Path: "#{gem_path}")
@@ -1209,15 +1217,16 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1209
1217
  end
1210
1218
 
1211
1219
  describe "log_dir_path" do
1212
- before { run_within_dir root_path }
1220
+ let(:log_path) { File.dirname(Appsignal.config.log_file_path) }
1221
+ before { run }
1213
1222
 
1214
1223
  it "outputs log directory path" do
1215
- expect(output).to match %(Log directory\n Path: "#{system_tmp_dir}")
1224
+ expect(output).to match %(Log directory\n Path: "#{log_path}")
1216
1225
  end
1217
1226
 
1218
1227
  it "transmits path data in report" do
1219
1228
  expect(received_report["paths"]["log_dir_path"]).to match(
1220
- "path" => system_tmp_dir,
1229
+ "path" => log_path,
1221
1230
  "exists" => true,
1222
1231
  "type" => "directory",
1223
1232
  "mode" => kind_of(String),
@@ -1235,15 +1244,15 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1235
1244
 
1236
1245
  context "when a directory does not exist" do
1237
1246
  let(:root_path) { tmp_dir }
1247
+ let(:environment) { nil }
1248
+ let(:push_api_key) { nil }
1249
+ let(:app_name) { nil }
1250
+ let(:options) { {} }
1238
1251
  let(:execution_path) { File.join(tmp_dir, "not_existing_dir") }
1239
- let(:config) do
1240
- silence(:allowed => ["Push api key not set after loading config"]) do
1241
- Appsignal::Config.new(execution_path, "production")
1242
- end
1243
- end
1244
1252
  before do
1245
1253
  allow(Dir).to receive(:pwd).and_return(execution_path)
1246
- run_within_dir tmp_dir
1254
+ FileUtils.rm_rf(execution_path)
1255
+ run_within_dir root_path
1247
1256
  end
1248
1257
 
1249
1258
  it "outputs not existing path" do
@@ -1260,7 +1269,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1260
1269
 
1261
1270
  context "when not writable" do
1262
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) { {} }
1263
1276
  before do
1277
+ FileUtils.mkdir_p(root_path)
1264
1278
  FileUtils.chmod(0o555, root_path)
1265
1279
  run_within_dir root_path
1266
1280
  end
@@ -1288,7 +1302,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1288
1302
 
1289
1303
  context "when writable" do
1290
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) { {} }
1291
1309
  before do
1310
+ FileUtils.mkdir_p(root_path)
1292
1311
  FileUtils.chmod(0o755, root_path)
1293
1312
  run_within_dir root_path
1294
1313
  end
@@ -1315,6 +1334,14 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
1315
1334
  end
1316
1335
 
1317
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
+
1318
1345
  context "when a directory is owned by the current user" do
1319
1346
  let(:root_path) { File.join(tmp_dir, "owned_path") }
1320
1347
  before { run_within_dir root_path }