appsignal 3.13.0 → 4.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +499 -487
  3. data/CHANGELOG.md +113 -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 +2 -15
  11. data/lib/appsignal/cli/diagnose.rb +37 -28
  12. data/lib/appsignal/cli/install.rb +5 -1
  13. data/lib/appsignal/config.rb +57 -119
  14. data/lib/appsignal/demo.rb +2 -2
  15. data/lib/appsignal/extension/jruby.rb +14 -0
  16. data/lib/appsignal/helpers/instrumentation.rb +139 -417
  17. data/lib/appsignal/helpers/metrics.rb +0 -16
  18. data/lib/appsignal/hooks/action_cable.rb +8 -8
  19. data/lib/appsignal/hooks/active_job.rb +2 -2
  20. data/lib/appsignal/hooks/at_exit.rb +37 -0
  21. data/lib/appsignal/hooks.rb +1 -16
  22. data/lib/appsignal/integrations/action_cable.rb +2 -2
  23. data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
  24. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
  25. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
  26. data/lib/appsignal/integrations/que.rb +2 -2
  27. data/lib/appsignal/integrations/railtie.rb +26 -59
  28. data/lib/appsignal/integrations/rake.rb +2 -2
  29. data/lib/appsignal/integrations/resque.rb +2 -2
  30. data/lib/appsignal/integrations/shoryuken.rb +4 -4
  31. data/lib/appsignal/integrations/sidekiq.rb +3 -3
  32. data/lib/appsignal/integrations/webmachine.rb +2 -2
  33. data/lib/appsignal/loaders.rb +1 -1
  34. data/lib/appsignal/probes.rb +0 -9
  35. data/lib/appsignal/rack/abstract_middleware.rb +4 -26
  36. data/lib/appsignal/rack/event_handler.rb +4 -4
  37. data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
  38. data/lib/appsignal/rack.rb +0 -25
  39. data/lib/appsignal/sample_data.rb +95 -0
  40. data/lib/appsignal/transaction.rb +235 -361
  41. data/lib/appsignal/utils/rails_helper.rb +4 -0
  42. data/lib/appsignal/version.rb +1 -1
  43. data/lib/appsignal.rb +19 -71
  44. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  45. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  46. data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
  47. data/spec/lib/appsignal/check_in_spec.rb +1 -207
  48. data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
  49. data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
  50. data/spec/lib/appsignal/config_spec.rb +304 -379
  51. data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
  52. data/spec/lib/appsignal/extension_spec.rb +5 -1
  53. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  54. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
  55. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
  56. data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
  57. data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
  58. data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
  59. data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
  60. data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
  61. data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
  62. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
  63. data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
  64. data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
  65. data/spec/lib/appsignal/hooks_spec.rb +0 -41
  66. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
  67. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
  68. data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
  69. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
  70. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
  71. data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
  72. data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
  73. data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
  74. data/spec/lib/appsignal/loaders_spec.rb +8 -1
  75. data/spec/lib/appsignal/marker_spec.rb +1 -1
  76. data/spec/lib/appsignal/probes_spec.rb +4 -83
  77. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
  78. data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
  79. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
  80. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
  81. data/spec/lib/appsignal/sample_data_spec.rb +174 -0
  82. data/spec/lib/appsignal/transaction_spec.rb +791 -1031
  83. data/spec/lib/appsignal/transmitter_spec.rb +6 -8
  84. data/spec/lib/appsignal_spec.rb +294 -643
  85. data/spec/spec_helper.rb +1 -3
  86. data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
  87. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
  88. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
  89. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
  90. data/spec/support/helpers/api_request_helper.rb +3 -2
  91. data/spec/support/helpers/config_helpers.rb +41 -11
  92. data/spec/support/helpers/dependency_helper.rb +8 -0
  93. data/spec/support/helpers/log_helpers.rb +1 -0
  94. data/spec/support/helpers/rails_helper.rb +6 -6
  95. data/spec/support/helpers/transaction_helpers.rb +2 -24
  96. data/spec/support/matchers/transaction.rb +3 -3
  97. data/spec/support/mocks/appsignal_mock.rb +3 -3
  98. data/spec/support/mocks/mock_probe.rb +2 -0
  99. data/spec/support/testing.rb +2 -2
  100. metadata +12 -22
  101. data/gemfiles/que_beta.gemfile +0 -5
  102. data/lib/appsignal/helpers/heartbeat.rb +0 -20
  103. data/lib/appsignal/integrations/grape.rb +0 -35
  104. data/lib/appsignal/integrations/hanami.rb +0 -13
  105. data/lib/appsignal/integrations/padrino.rb +0 -13
  106. data/lib/appsignal/integrations/sinatra.rb +0 -13
  107. data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
  108. data/lib/appsignal/rack/streaming_listener.rb +0 -28
  109. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
  110. data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
  111. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
  112. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
  113. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
  114. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
  115. data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
  116. data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
  117. data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
  118. data/spec/support/rails/my_app.rb +0 -6
  119. /data/spec/support/fixtures/projects/{valid/config/application.rb → valid_with_rails_app/log/.gitkeep} +0 -0
@@ -1,36 +0,0 @@
1
- if DependencyHelper.grape_present?
2
- require "appsignal/integrations/grape"
3
-
4
- context "Appsignal::Grape::Middleware constant" do
5
- let(:err_stream) { std_stream }
6
- let(:stderr) { err_stream.read }
7
-
8
- it "returns the Rack::GrapeMiddleware constant calling the Grape::Middleware constant" do
9
- silence { expect(Appsignal::Grape::Middleware).to be(Appsignal::Rack::GrapeMiddleware) }
10
- end
11
-
12
- it "prints a deprecation warning to STDERR" do
13
- capture_std_streams(std_stream, err_stream) do
14
- expect(Appsignal::Grape::Middleware).to be(Appsignal::Rack::GrapeMiddleware)
15
- end
16
-
17
- expect(stderr).to include(
18
- "appsignal WARNING: The constant Appsignal::Grape::Middleware has been deprecated."
19
- )
20
- end
21
-
22
- it "logs a warning" do
23
- logs =
24
- capture_logs do
25
- silence do
26
- expect(Appsignal::Grape::Middleware).to be(Appsignal::Rack::GrapeMiddleware)
27
- end
28
- end
29
-
30
- expect(logs).to contains_log(
31
- :warn,
32
- "The constant Appsignal::Grape::Middleware has been deprecated."
33
- )
34
- end
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if DependencyHelper.hanami_present?
4
- describe "Hanami integration" do
5
- it "loads the Hanami loader" do
6
- ENV["APPSIGNAL_APP_NAME"] = "test/sinatra"
7
- ENV["APPSIGNAL_PUSH_API_KEY"] = "test-key"
8
-
9
- require "appsignal/integrations/hanami"
10
-
11
- expect(Appsignal::Loaders.instances).to include(
12
- :hanami => kind_of(Appsignal::Loaders::HanamiLoader)
13
- )
14
- expect(Appsignal.active?).to be(true)
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- if DependencyHelper.padrino_present?
2
- describe "Padrino integration" do
3
- it "loads the Padrino loader" do
4
- ENV["APPSIGNAL_APP_NAME"] = "test/sinatra"
5
- ENV["APPSIGNAL_PUSH_API_KEY"] = "test-key"
6
-
7
- require "appsignal/integrations/padrino"
8
-
9
- expect(Appsignal::Loaders.instances).to include(
10
- :padrino => kind_of(Appsignal::Loaders::PadrinoLoader)
11
- )
12
- expect(Appsignal.active?).to be(true)
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- if DependencyHelper.padrino_present?
2
- describe "Sinatra integration" do
3
- it "loads the Sinatra loader" do
4
- ENV["APPSIGNAL_APP_NAME"] = "test/sinatra"
5
- ENV["APPSIGNAL_PUSH_API_KEY"] = "test-key"
6
-
7
- require "appsignal/integrations/sinatra"
8
-
9
- expect(Appsignal::Loaders.instances).to include(
10
- :sinatra => kind_of(Appsignal::Loaders::SinatraLoader)
11
- )
12
- expect(Appsignal.active?).to be(true)
13
- end
14
- end
15
- end
@@ -1,81 +0,0 @@
1
- describe "Appsignal::Rack::GenericInstrumentation" do
2
- describe "Appsignal::Rack::GenericInstrumentation constant" do
3
- let(:err_stream) { std_stream }
4
- let(:stderr) { err_stream.read }
5
- before do
6
- if Appsignal::Rack.const_defined?(:GenericInstrumentation)
7
- hide_const "Appsignal::Rack::GenericInstrumentation"
8
- end
9
- end
10
-
11
- it "returns the Rack::GenericInstrumentation constant" do
12
- silence do
13
- expect(Appsignal::Rack::GenericInstrumentation)
14
- .to be(Appsignal::Rack::GenericInstrumentationAlias)
15
- end
16
- end
17
-
18
- it "prints a deprecation warning to STDERR" do
19
- capture_std_streams(std_stream, err_stream) do
20
- Appsignal::Rack::GenericInstrumentation
21
- end
22
-
23
- expect(stderr).to include(
24
- "appsignal WARNING: The constant Appsignal::Rack::GenericInstrumentation " \
25
- "has been deprecated."
26
- )
27
- end
28
-
29
- it "logs a warning" do
30
- logs =
31
- capture_logs do
32
- silence do
33
- Appsignal::Rack::GenericInstrumentation
34
- end
35
- end
36
-
37
- expect(logs).to contains_log(
38
- :warn,
39
- "The constant Appsignal::Rack::GenericInstrumentation has been deprecated."
40
- )
41
- end
42
- end
43
-
44
- describe "middleware" do
45
- let(:app) { double(:call => true) }
46
- let(:env) { Rack::MockRequest.env_for("/some/path") }
47
- let(:middleware) { Appsignal::Rack::GenericInstrumentation.new(app, {}) }
48
-
49
- before { start_agent }
50
- around { |example| keep_transactions { example.run } }
51
-
52
- def make_request(env)
53
- middleware.call(env)
54
- end
55
-
56
- context "without an exception" do
57
- it "reports a process_action.generic event" do
58
- make_request(env)
59
-
60
- expect(last_transaction).to include_event("name" => "process_action.generic")
61
- end
62
- end
63
-
64
- context "with action name env" do
65
- it "reports the appsignal.action env as the action name" do
66
- env["appsignal.action"] = "MyAction"
67
- make_request(env)
68
-
69
- expect(last_transaction).to have_action("MyAction")
70
- end
71
- end
72
-
73
- context "without action name metadata" do
74
- it "reports 'unknown' as the action name" do
75
- make_request(env)
76
-
77
- expect(last_transaction).to have_action("unknown")
78
- end
79
- end
80
- end
81
- end
@@ -1,69 +0,0 @@
1
- describe "Appsignal::Rack::StreamingListener" do
2
- def load_middleware
3
- load "lib/appsignal/rack/streaming_listener.rb"
4
- end
5
-
6
- describe "loading the streaming_listener integrations file" do
7
- let(:err_stream) { std_stream }
8
- let(:stderr) { err_stream.read }
9
- after { Appsignal::Rack.send(:remove_const, :StreamingListener) }
10
-
11
- it "prints a deprecation warning to STDERR" do
12
- capture_std_streams(std_stream, err_stream) do
13
- load_middleware
14
- end
15
-
16
- expect(stderr).to include(
17
- "appsignal WARNING: The constant Appsignal::Rack::StreamingListener " \
18
- "has been deprecated."
19
- )
20
- end
21
-
22
- it "logs a warning" do
23
- logs =
24
- capture_logs do
25
- silence do
26
- load_middleware
27
- end
28
- end
29
-
30
- expect(logs).to contains_log(
31
- :warn,
32
- "The constant Appsignal::Rack::StreamingListener has been deprecated."
33
- )
34
- end
35
- end
36
-
37
- describe "middleware" do
38
- let(:env) { {} }
39
- let(:app) { DummyApp.new }
40
- let(:middleware) { Appsignal::Rack::StreamingListener.new(app, {}) }
41
- around { |example| keep_transactions { example.run } }
42
- before(:context) { load_middleware }
43
- before { start_agent }
44
-
45
- def make_request
46
- middleware.call(env)
47
- end
48
-
49
- it "instruments the call" do
50
- make_request
51
-
52
- expect(last_transaction).to include_event("name" => "process_streaming_request.rack")
53
- end
54
-
55
- it "set no action by default" do
56
- make_request
57
-
58
- expect(last_transaction).to_not have_action
59
- end
60
-
61
- it "set `appsignal.action` to the action name" do
62
- env["appsignal.action"] = "Action"
63
-
64
- make_request
65
-
66
- expect(last_transaction).to have_action("Action")
67
- end
68
- end
69
- end
@@ -1,6 +0,0 @@
1
- module MyApp
2
- class Application < Rails::Application
3
- config.active_support.deprecation = proc { |message, stack| }
4
- config.eager_load = false
5
- end
6
- end