appsignal 4.0.5 → 4.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Rakefile +9 -9
- data/appsignal.gemspec +22 -1
- data/build_matrix.yml +2 -1
- data/ext/agent.rb +27 -27
- data/lib/appsignal/check_in/scheduler.rb +3 -4
- data/lib/appsignal/check_in.rb +1 -1
- data/lib/appsignal/config.rb +1 -3
- data/lib/appsignal/integrations/que.rb +8 -2
- data/lib/appsignal/integrations/resque.rb +1 -6
- data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- metadata +2 -191
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/chore.md +0 -14
- data/.github/workflows/ci.yml +0 -3150
- data/.github/workflows/create_release_from_tag.yml +0 -62
- data/.gitignore +0 -35
- data/.gitmodules +0 -3
- data/.rspec +0 -4
- data/.yardopts +0 -8
- data/benchmark.rake +0 -139
- data/gemfiles/capistrano2.gemfile +0 -6
- data/gemfiles/capistrano3.gemfile +0 -7
- data/gemfiles/dry-monitor.gemfile +0 -5
- data/gemfiles/grape.gemfile +0 -5
- data/gemfiles/hanami-2.0.gemfile +0 -7
- data/gemfiles/hanami-2.1.gemfile +0 -7
- data/gemfiles/http5.gemfile +0 -5
- data/gemfiles/no_dependencies.gemfile +0 -10
- data/gemfiles/padrino.gemfile +0 -7
- data/gemfiles/psych-3.gemfile +0 -5
- data/gemfiles/psych-4.gemfile +0 -5
- data/gemfiles/que.gemfile +0 -5
- data/gemfiles/rails-6.0.gemfile +0 -10
- data/gemfiles/rails-6.1.gemfile +0 -11
- data/gemfiles/rails-7.0.gemfile +0 -11
- data/gemfiles/rails-7.1.gemfile +0 -11
- data/gemfiles/rails-7.2.gemfile +0 -11
- data/gemfiles/redis-4.gemfile +0 -5
- data/gemfiles/redis-5.gemfile +0 -6
- data/gemfiles/resque-2.gemfile +0 -6
- data/gemfiles/sequel.gemfile +0 -10
- data/gemfiles/sinatra.gemfile +0 -5
- data/gemfiles/webmachine1.gemfile +0 -7
- data/gemfiles/webmachine2.gemfile +0 -6
- data/mono.yml +0 -16
- data/spec/.rubocop.yml +0 -7
- data/spec/lib/appsignal/auth_check_spec.rb +0 -84
- data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
- data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
- data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
- data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
- data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
- data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
- data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
- data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
- data/spec/lib/appsignal/cli/install_spec.rb +0 -848
- data/spec/lib/appsignal/cli_spec.rb +0 -56
- data/spec/lib/appsignal/config_spec.rb +0 -1380
- data/spec/lib/appsignal/demo_spec.rb +0 -83
- data/spec/lib/appsignal/environment_spec.rb +0 -190
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
- data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
- data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
- data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
- data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
- data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
- data/spec/lib/appsignal/extension_spec.rb +0 -178
- data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
- data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
- data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
- data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
- data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
- data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
- data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
- data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
- data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
- data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
- data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
- data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
- data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
- data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
- data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
- data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
- data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
- data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
- data/spec/lib/appsignal/hooks_spec.rb +0 -124
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
- data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
- data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
- data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
- data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
- data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
- data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
- data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
- data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
- data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
- data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
- data/spec/lib/appsignal/loaders_spec.rb +0 -144
- data/spec/lib/appsignal/logger_spec.rb +0 -205
- data/spec/lib/appsignal/marker_spec.rb +0 -51
- data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
- data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
- data/spec/lib/appsignal/probes_spec.rb +0 -411
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
- data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
- data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
- data/spec/lib/appsignal/rack_spec.rb +0 -243
- data/spec/lib/appsignal/sample_data_spec.rb +0 -238
- data/spec/lib/appsignal/span_spec.rb +0 -141
- data/spec/lib/appsignal/system_spec.rb +0 -126
- data/spec/lib/appsignal/transaction_spec.rb +0 -2111
- data/spec/lib/appsignal/transmitter_spec.rb +0 -198
- data/spec/lib/appsignal/utils/data_spec.rb +0 -166
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
- data/spec/lib/appsignal/utils/json_spec.rb +0 -44
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
- data/spec/lib/appsignal_spec.rb +0 -1919
- data/spec/lib/puma/appsignal_spec.rb +0 -334
- data/spec/spec_helper.rb +0 -173
- data/spec/support/fixtures/generated_config.yml +0 -24
- data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
- data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
- data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
- data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
- data/spec/support/fixtures/uploaded_file.txt +0 -0
- data/spec/support/hanami/hanami_app.rb +0 -29
- data/spec/support/helpers/action_mailer_helpers.rb +0 -25
- data/spec/support/helpers/activejob_helpers.rb +0 -27
- data/spec/support/helpers/api_request_helper.rb +0 -20
- data/spec/support/helpers/cli_helpers.rb +0 -40
- data/spec/support/helpers/config_helpers.rb +0 -66
- data/spec/support/helpers/dependency_helper.rb +0 -150
- data/spec/support/helpers/directory_helper.rb +0 -27
- data/spec/support/helpers/env_helpers.rb +0 -41
- data/spec/support/helpers/environment_metdata_helper.rb +0 -16
- data/spec/support/helpers/example_exception.rb +0 -13
- data/spec/support/helpers/example_standard_error.rb +0 -13
- data/spec/support/helpers/loader_helper.rb +0 -21
- data/spec/support/helpers/log_helpers.rb +0 -36
- data/spec/support/helpers/rails_helper.rb +0 -28
- data/spec/support/helpers/std_streams_helper.rb +0 -94
- data/spec/support/helpers/system_helpers.rb +0 -8
- data/spec/support/helpers/take_at_most_helper.rb +0 -21
- data/spec/support/helpers/time_helpers.rb +0 -11
- data/spec/support/helpers/transaction_helpers.rb +0 -122
- data/spec/support/helpers/wait_for_helper.rb +0 -39
- data/spec/support/matchers/contains_log.rb +0 -26
- data/spec/support/matchers/have_colorized_text.rb +0 -28
- data/spec/support/matchers/transaction.rb +0 -200
- data/spec/support/mocks/appsignal_mock.rb +0 -18
- data/spec/support/mocks/dummy_app.rb +0 -20
- data/spec/support/mocks/fake_gc_profiler.rb +0 -19
- data/spec/support/mocks/fake_gvl_tools.rb +0 -28
- data/spec/support/mocks/hash_like.rb +0 -10
- data/spec/support/mocks/mock_probe.rb +0 -13
- data/spec/support/mocks/puma_mock.rb +0 -43
- data/spec/support/shared_examples/instrument.rb +0 -48
- data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
- data/spec/support/stubs/delayed_job.rb +0 -0
- data/spec/support/stubs/sidekiq/api.rb +0 -4
- data/spec/support/testing.rb +0 -194
- data/support/bundler_wrapper +0 -12
- data/support/install_deps +0 -33
@@ -1,80 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::PumaHook do
|
2
|
-
context "with puma" do
|
3
|
-
let(:puma_version) { "6.0.0" }
|
4
|
-
before do
|
5
|
-
stub_const("Puma", PumaMock)
|
6
|
-
stub_const("Puma::Const::VERSION", puma_version)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#dependencies_present?" do
|
10
|
-
subject { described_class.new.dependencies_present? }
|
11
|
-
|
12
|
-
context "when Puma present" do
|
13
|
-
context "when Puma is newer than version 3.0.0" do
|
14
|
-
let(:puma_version) { "3.0.0" }
|
15
|
-
|
16
|
-
it { is_expected.to be_truthy }
|
17
|
-
end
|
18
|
-
|
19
|
-
context "when Puma is older than version 3.0.0" do
|
20
|
-
let(:puma_version) { "2.9.9" }
|
21
|
-
|
22
|
-
it { is_expected.to be_falsey }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when Puma is not present" do
|
27
|
-
before do
|
28
|
-
hide_const("Puma")
|
29
|
-
end
|
30
|
-
|
31
|
-
it { is_expected.to be_falsey }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "installation" do
|
36
|
-
before { Appsignal::Probes.probes.clear }
|
37
|
-
|
38
|
-
it "adds the Puma::Server patch" do
|
39
|
-
Appsignal::Hooks::PumaHook.new.install
|
40
|
-
expect(::Puma::Server.included_modules).to include(Appsignal::Integrations::PumaServer)
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when not clustered mode" do
|
44
|
-
it "does not add AppSignal stop behavior Puma::Cluster" do
|
45
|
-
expect(defined?(::Puma::Cluster)).to be_falsy
|
46
|
-
# Does not error on call
|
47
|
-
Appsignal::Hooks::PumaHook.new.install
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when in clustered mode" do
|
52
|
-
before do
|
53
|
-
stub_const("Puma::Cluster", Class.new do
|
54
|
-
def stop_workers
|
55
|
-
@called = true
|
56
|
-
end
|
57
|
-
end)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "adds behavior to Puma::Cluster.stop_workers" do
|
61
|
-
Appsignal::Hooks::PumaHook.new.install
|
62
|
-
cluster = Puma::Cluster.new
|
63
|
-
|
64
|
-
expect(cluster.instance_variable_defined?(:@called)).to be_falsy
|
65
|
-
expect(Appsignal).to receive(:stop).and_call_original
|
66
|
-
cluster.stop_workers
|
67
|
-
expect(cluster.instance_variable_get(:@called)).to be(true)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "without puma" do
|
74
|
-
describe "#dependencies_present?" do
|
75
|
-
subject { described_class.new.dependencies_present? }
|
76
|
-
|
77
|
-
it { is_expected.to be_falsy }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::QueHook do
|
2
|
-
if DependencyHelper.que_present?
|
3
|
-
describe "#dependencies_present?" do
|
4
|
-
subject { described_class.new.dependencies_present? }
|
5
|
-
|
6
|
-
it { is_expected.to be_truthy }
|
7
|
-
end
|
8
|
-
|
9
|
-
it "installs the QuePlugin" do
|
10
|
-
expect(Que::Job.included_modules).to include(Appsignal::Integrations::QuePlugin)
|
11
|
-
end
|
12
|
-
else
|
13
|
-
describe "#dependencies_present?" do
|
14
|
-
subject { described_class.new.dependencies_present? }
|
15
|
-
|
16
|
-
it { is_expected.to be_falsy }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
require "rake"
|
2
|
-
|
3
|
-
describe Appsignal::Hooks::RakeHook do
|
4
|
-
let(:helper) { Appsignal::Integrations::RakeIntegrationHelper }
|
5
|
-
let(:task) { Rake::Task.new("task:name", Rake::Application.new) }
|
6
|
-
let(:arguments) { Rake::TaskArguments.new(["foo"], ["bar"]) }
|
7
|
-
let(:options) { {} }
|
8
|
-
before do
|
9
|
-
start_agent(:options => options)
|
10
|
-
allow(Kernel).to receive(:at_exit)
|
11
|
-
end
|
12
|
-
around { |example| keep_transactions { example.run } }
|
13
|
-
after do
|
14
|
-
if helper.instance_variable_defined?(:@register_at_exit_hook)
|
15
|
-
helper.remove_instance_variable(:@register_at_exit_hook)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def expect_to_not_have_registered_at_exit_hook
|
20
|
-
expect(Kernel).to_not have_received(:at_exit)
|
21
|
-
end
|
22
|
-
|
23
|
-
def expect_to_have_registered_at_exit_hook
|
24
|
-
expect(Kernel).to have_received(:at_exit)
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#execute" do
|
28
|
-
context "without error" do
|
29
|
-
def perform
|
30
|
-
task.execute(arguments)
|
31
|
-
end
|
32
|
-
|
33
|
-
context "with :enable_rake_performance_instrumentation == false" do
|
34
|
-
let(:options) { { :enable_rake_performance_instrumentation => false } }
|
35
|
-
|
36
|
-
it "creates no transaction" do
|
37
|
-
expect { perform }.to_not(change { created_transactions.count })
|
38
|
-
end
|
39
|
-
|
40
|
-
it "calls the original task" do
|
41
|
-
expect(perform).to eq([])
|
42
|
-
end
|
43
|
-
|
44
|
-
it "does not register an at_exit hook" do
|
45
|
-
perform
|
46
|
-
expect_to_not_have_registered_at_exit_hook
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with :enable_rake_performance_instrumentation == true" do
|
51
|
-
let(:options) { { :enable_rake_performance_instrumentation => true } }
|
52
|
-
|
53
|
-
it "creates a transaction" do
|
54
|
-
expect { perform }.to(change { created_transactions.count }.by(1))
|
55
|
-
|
56
|
-
transaction = last_transaction
|
57
|
-
expect(transaction).to have_id
|
58
|
-
expect(transaction).to have_namespace("rake")
|
59
|
-
expect(transaction).to have_action("task:name")
|
60
|
-
expect(transaction).to_not have_error
|
61
|
-
expect(transaction).to include_params("foo" => "bar")
|
62
|
-
expect(transaction).to include_event("name" => "task.rake")
|
63
|
-
expect(transaction).to be_completed
|
64
|
-
end
|
65
|
-
|
66
|
-
it "calls the original task" do
|
67
|
-
expect(perform).to eq([])
|
68
|
-
end
|
69
|
-
|
70
|
-
it "registers an at_exit hook" do
|
71
|
-
perform
|
72
|
-
expect_to_have_registered_at_exit_hook
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with error" do
|
78
|
-
before do
|
79
|
-
task.enhance { raise ExampleException, "error message" }
|
80
|
-
end
|
81
|
-
|
82
|
-
def perform
|
83
|
-
expect { task.execute(arguments) }.to raise_error(ExampleException, "error message")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "creates a background job transaction" do
|
87
|
-
perform
|
88
|
-
|
89
|
-
transaction = last_transaction
|
90
|
-
expect(transaction).to have_id
|
91
|
-
expect(transaction).to have_namespace("rake")
|
92
|
-
expect(transaction).to have_action("task:name")
|
93
|
-
expect(transaction).to have_error("ExampleException", "error message")
|
94
|
-
expect(transaction).to include_params("foo" => "bar")
|
95
|
-
expect(transaction).to be_completed
|
96
|
-
end
|
97
|
-
|
98
|
-
it "registers an at_exit hook" do
|
99
|
-
perform
|
100
|
-
expect_to_have_registered_at_exit_hook
|
101
|
-
end
|
102
|
-
|
103
|
-
context "when first argument is not a `Rake::TaskArguments`" do
|
104
|
-
let(:arguments) { nil }
|
105
|
-
|
106
|
-
it "does not add the params to the transaction" do
|
107
|
-
perform
|
108
|
-
|
109
|
-
expect(last_transaction).to_not include_params
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "Appsignal::Integrations::RakeIntegrationHelper" do
|
117
|
-
let(:helper) { Appsignal::Integrations::RakeIntegrationHelper }
|
118
|
-
describe ".register_at_exit_hook" do
|
119
|
-
before do
|
120
|
-
start_agent
|
121
|
-
allow(Appsignal).to receive(:stop)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "registers the at_exit hook only once" do
|
125
|
-
allow(Kernel).to receive(:at_exit)
|
126
|
-
helper.register_at_exit_hook
|
127
|
-
helper.register_at_exit_hook
|
128
|
-
expect(Kernel).to have_received(:at_exit).once
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe ".at_exit_hook" do
|
133
|
-
let(:helper) { Appsignal::Integrations::RakeIntegrationHelper }
|
134
|
-
before do
|
135
|
-
start_agent
|
136
|
-
allow(Appsignal).to receive(:stop)
|
137
|
-
end
|
138
|
-
|
139
|
-
it "calls Appsignal.stop" do
|
140
|
-
helper.at_exit_hook
|
141
|
-
expect(Appsignal).to have_received(:stop).with("rake")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
@@ -1,218 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::RedisClientHook do
|
2
|
-
let(:options) { {} }
|
3
|
-
before do
|
4
|
-
start_agent(:options => options)
|
5
|
-
end
|
6
|
-
|
7
|
-
if DependencyHelper.redis_client_present?
|
8
|
-
context "with redis-client" do
|
9
|
-
context "with instrumentation enabled" do
|
10
|
-
describe "#dependencies_present?" do
|
11
|
-
subject { described_class.new.dependencies_present? }
|
12
|
-
|
13
|
-
context "with gem version new than 0.14.0" do
|
14
|
-
before { stub_const("RedisClient::VERSION", "1.2.3") }
|
15
|
-
|
16
|
-
it { is_expected.to be_truthy }
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with gem version 0.14.0" do
|
20
|
-
before { stub_const("RedisClient::VERSION", "0.14.0") }
|
21
|
-
|
22
|
-
it { is_expected.to be_truthy }
|
23
|
-
end
|
24
|
-
|
25
|
-
context "with gem version older than 0.14.0" do
|
26
|
-
before { stub_const("RedisClient::VERSION", "0.13.9") }
|
27
|
-
|
28
|
-
it { is_expected.to be_falsy }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with rest-client gem" do
|
33
|
-
describe "integration" do
|
34
|
-
let(:options) { { :instrument_redis => true } }
|
35
|
-
|
36
|
-
context "install" do
|
37
|
-
before do
|
38
|
-
Appsignal::Hooks.load_hooks
|
39
|
-
end
|
40
|
-
|
41
|
-
it "includes the integration for the ruby connection" do
|
42
|
-
# Test if the last included module (prepended module) was our
|
43
|
-
# integration. That's not certain with the assertions below
|
44
|
-
# because we have to overwrite the `process` method for the test.
|
45
|
-
expect(RedisClient::RubyConnection.included_modules.first)
|
46
|
-
.to eql(Appsignal::Integrations::RedisClientIntegration)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "requirements" do
|
51
|
-
it "driver should have the write method" do
|
52
|
-
# Since we stub the driver class below, to make sure that we don't
|
53
|
-
# create a real connection, the test won't fail if the method definition
|
54
|
-
# is changed.
|
55
|
-
method = RedisClient::RubyConnection.instance_method(:write)
|
56
|
-
expect(method.arity).to eql(1)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "instrumentation" do
|
61
|
-
before do
|
62
|
-
start_agent
|
63
|
-
# Stub RedisClient::RubyConnection class so that it doesn't perform an actual
|
64
|
-
# Redis query. This class will be included (prepended) with the
|
65
|
-
# AppSignal Redis integration.
|
66
|
-
stub_const("RedisClient::RubyConnection", Class.new do
|
67
|
-
def initialize(config)
|
68
|
-
@config = config
|
69
|
-
end
|
70
|
-
|
71
|
-
def write(_commands)
|
72
|
-
"stub_write"
|
73
|
-
end
|
74
|
-
end)
|
75
|
-
# Load the integration again for the stubbed RedisClient::RubyConnection class.
|
76
|
-
# Call it directly because {Appsignal::Hooks.load_hooks} keeps
|
77
|
-
# track if it was installed already or not.
|
78
|
-
Appsignal::Hooks::RedisClientHook.new.install
|
79
|
-
end
|
80
|
-
let(:transaction) { http_request_transaction }
|
81
|
-
let!(:client_config) { RedisClient::Config.new(:id => "stub_id") }
|
82
|
-
before { set_current_transaction(transaction) }
|
83
|
-
around { |example| keep_transactions { example.run } }
|
84
|
-
|
85
|
-
it "instrument a redis call" do
|
86
|
-
connection = RedisClient::RubyConnection.new client_config
|
87
|
-
expect(connection.write([:get, "key"])).to eql("stub_write")
|
88
|
-
|
89
|
-
expect(transaction).to include_event(
|
90
|
-
"name" => "query.redis",
|
91
|
-
"body" => "get ?",
|
92
|
-
"title" => "stub_id"
|
93
|
-
)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "instrument a redis script call" do
|
97
|
-
connection = ::RedisClient::RubyConnection.new client_config
|
98
|
-
script = "return redis.call('set',KEYS[1],ARGV[1])"
|
99
|
-
keys = ["foo"]
|
100
|
-
argv = ["bar"]
|
101
|
-
expect(connection.write([:eval, script, keys.size, keys, argv]))
|
102
|
-
.to eql("stub_write")
|
103
|
-
|
104
|
-
expect(transaction).to include_event(
|
105
|
-
"name" => "query.redis",
|
106
|
-
"body" => "#{script} ? ?",
|
107
|
-
"title" => "stub_id"
|
108
|
-
)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
if DependencyHelper.hiredis_client_present?
|
115
|
-
context "with hiredis driver" do
|
116
|
-
describe "integration" do
|
117
|
-
let(:options) { { :instrument_redis => true } }
|
118
|
-
|
119
|
-
context "install" do
|
120
|
-
before do
|
121
|
-
Appsignal::Hooks.load_hooks
|
122
|
-
end
|
123
|
-
|
124
|
-
it "includes the integration in the HiredisConnection class" do
|
125
|
-
# Test if the last included module (prepended module) was our
|
126
|
-
# integration. That's not certain with the assertions below
|
127
|
-
# because we have to overwrite the `process` method for the test.
|
128
|
-
expect(RedisClient::HiredisConnection.included_modules.first)
|
129
|
-
.to eql(Appsignal::Integrations::RedisClientIntegration)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "requirements" do
|
134
|
-
it "driver should have the write method" do
|
135
|
-
# Since we stub the driver class below, to make sure that we don't
|
136
|
-
# create a real connection, the test won't fail if the method definition
|
137
|
-
# is changed.
|
138
|
-
method = RedisClient::HiredisConnection.instance_method(:write)
|
139
|
-
expect(method.arity).to eql(1)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "instrumentation" do
|
144
|
-
before do
|
145
|
-
start_agent
|
146
|
-
# Stub RedisClient::HiredisConnection class so that it doesn't perform an actual
|
147
|
-
# Redis query. This class will be included (prepended) with the
|
148
|
-
# AppSignal Redis integration.
|
149
|
-
stub_const("RedisClient::HiredisConnection", Class.new do
|
150
|
-
def initialize(config)
|
151
|
-
@config = config
|
152
|
-
end
|
153
|
-
|
154
|
-
def write(_commands)
|
155
|
-
"stub_write"
|
156
|
-
end
|
157
|
-
end)
|
158
|
-
# Load the integration again for the stubbed RedisClient::HiredisConnection class.
|
159
|
-
# Call it directly because {Appsignal::Hooks.load_hooks} keeps
|
160
|
-
# track if it was installed already or not.
|
161
|
-
Appsignal::Hooks::RedisClientHook.new.install
|
162
|
-
end
|
163
|
-
let(:transaction) { http_request_transaction }
|
164
|
-
let!(:client_config) { RedisClient::Config.new(:id => "stub_id") }
|
165
|
-
before { set_current_transaction(transaction) }
|
166
|
-
around { |example| keep_transactions { example.run } }
|
167
|
-
|
168
|
-
it "instrument a redis call" do
|
169
|
-
connection = RedisClient::HiredisConnection.new client_config
|
170
|
-
expect(connection.write([:get, "key"])).to eql("stub_write")
|
171
|
-
|
172
|
-
expect(transaction).to include_event(
|
173
|
-
"name" => "query.redis",
|
174
|
-
"body" => "get ?",
|
175
|
-
"title" => "stub_id"
|
176
|
-
)
|
177
|
-
end
|
178
|
-
|
179
|
-
it "instrument a redis script call" do
|
180
|
-
connection = ::RedisClient::HiredisConnection.new client_config
|
181
|
-
script = "return redis.call('set',KEYS[1],ARGV[1])"
|
182
|
-
keys = ["foo"]
|
183
|
-
argv = ["bar"]
|
184
|
-
expect(connection.write([:eval, script, keys.size, keys,
|
185
|
-
argv])).to eql("stub_write")
|
186
|
-
|
187
|
-
expect(transaction).to include_event(
|
188
|
-
"name" => "query.redis",
|
189
|
-
"body" => "#{script} ? ?",
|
190
|
-
"title" => "stub_id"
|
191
|
-
)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context "with instrumentation disabled" do
|
200
|
-
let(:options) { { :instrument_redis => false } }
|
201
|
-
|
202
|
-
describe "#dependencies_present?" do
|
203
|
-
subject { described_class.new.dependencies_present? }
|
204
|
-
|
205
|
-
it { is_expected.to be_falsy }
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
else
|
210
|
-
context "without redis-client" do
|
211
|
-
describe "#dependencies_present?" do
|
212
|
-
subject { described_class.new.dependencies_present? }
|
213
|
-
|
214
|
-
it { is_expected.to be_falsy }
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::RedisHook do
|
2
|
-
let(:options) { {} }
|
3
|
-
before { start_agent(:options => options) }
|
4
|
-
|
5
|
-
if DependencyHelper.redis_present?
|
6
|
-
context "with redis" do
|
7
|
-
if DependencyHelper.redis_client_present?
|
8
|
-
context "with redis-client" do
|
9
|
-
context "with instrumentation enabled" do
|
10
|
-
describe "#dependencies_present?" do
|
11
|
-
subject { described_class.new.dependencies_present? }
|
12
|
-
|
13
|
-
it { is_expected.to be_falsey }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
else
|
18
|
-
context "with instrumentation enabled" do
|
19
|
-
describe "#dependencies_present?" do
|
20
|
-
subject { described_class.new.dependencies_present? }
|
21
|
-
|
22
|
-
it { is_expected.to be_truthy }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "integration" do
|
26
|
-
let(:options) { { :instrument_redis => true } }
|
27
|
-
|
28
|
-
context "install" do
|
29
|
-
before do
|
30
|
-
Appsignal::Hooks.load_hooks
|
31
|
-
end
|
32
|
-
|
33
|
-
it "prepends instrumentation module" do
|
34
|
-
# Test if the last included module (prepended module) was our
|
35
|
-
# integration. That's not certain with the assertions below
|
36
|
-
# because we have to overwrite the `process` method for the test.
|
37
|
-
expect(Redis::Client.included_modules.first)
|
38
|
-
.to eql(Appsignal::Integrations::RedisIntegration)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "requirements" do
|
43
|
-
it "driver should have the write method" do
|
44
|
-
# Since we stub the client class below, to make sure that we don't
|
45
|
-
# create a real connection, the test won't fail if the method definition
|
46
|
-
# is changed.
|
47
|
-
method = Redis::Client.instance_method(:call)
|
48
|
-
expect(method.arity).to eql(1)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "instrumentation" do
|
53
|
-
before do
|
54
|
-
start_agent
|
55
|
-
# Stub Redis::Client class so that it doesn't perform an actual
|
56
|
-
# Redis query. This class will be included (prepended) with the
|
57
|
-
# AppSignal Redis integration.
|
58
|
-
stub_const("Redis::Client", Class.new do
|
59
|
-
def id
|
60
|
-
"stub_id"
|
61
|
-
end
|
62
|
-
|
63
|
-
def write(_commands)
|
64
|
-
"stub_write"
|
65
|
-
end
|
66
|
-
end)
|
67
|
-
# Load the integration again for the stubbed Redis::Client class.
|
68
|
-
# Call it directly because {Appsignal::Hooks.load_hooks} keeps
|
69
|
-
# track if it was installed already or not.
|
70
|
-
Appsignal::Hooks::RedisHook.new.install
|
71
|
-
end
|
72
|
-
let(:transaction) { http_request_transaction }
|
73
|
-
before { set_current_transaction(transaction) }
|
74
|
-
around { |example| keep_transactions { example.run } }
|
75
|
-
|
76
|
-
it "instrument a redis call" do
|
77
|
-
client = Redis::Client.new
|
78
|
-
expect(client.write([:get, "key"])).to eql("stub_write")
|
79
|
-
|
80
|
-
expect(transaction).to include_event(
|
81
|
-
"name" => "query.redis",
|
82
|
-
"body" => "get ?",
|
83
|
-
"title" => "stub_id"
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "instrument a redis script call" do
|
88
|
-
client = Redis::Client.new
|
89
|
-
script = "return redis.call('set',KEYS[1],ARGV[1])"
|
90
|
-
keys = ["foo"]
|
91
|
-
argv = ["bar"]
|
92
|
-
expect(client.write([:eval, script, keys.size, keys, argv])).to eql("stub_write")
|
93
|
-
|
94
|
-
expect(transaction).to include_event(
|
95
|
-
"name" => "query.redis",
|
96
|
-
"body" => "#{script} ? ?",
|
97
|
-
"title" => "stub_id"
|
98
|
-
)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "with instrumentation disabled" do
|
105
|
-
let(:options) { { :instrument_redis => false } }
|
106
|
-
|
107
|
-
describe "#dependencies_present?" do
|
108
|
-
subject { described_class.new.dependencies_present? }
|
109
|
-
|
110
|
-
it { is_expected.to be_falsy }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
else
|
116
|
-
context "without redis" do
|
117
|
-
describe "#dependencies_present?" do
|
118
|
-
subject { described_class.new.dependencies_present? }
|
119
|
-
|
120
|
-
it { is_expected.to be_falsy }
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::ResqueHook do
|
2
|
-
describe "#dependency_present?" do
|
3
|
-
subject { described_class.new.dependencies_present? }
|
4
|
-
|
5
|
-
context "when Resque is loaded" do
|
6
|
-
before { stub_const "Resque", 1 }
|
7
|
-
|
8
|
-
it { is_expected.to be_truthy }
|
9
|
-
end
|
10
|
-
|
11
|
-
context "when Resque is not loaded" do
|
12
|
-
before { hide_const "Resque" }
|
13
|
-
|
14
|
-
it { is_expected.to be_falsy }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
if DependencyHelper.resque_present?
|
19
|
-
describe "#install" do
|
20
|
-
before { start_agent }
|
21
|
-
|
22
|
-
it "adds the ResqueIntegration module to Resque::Job" do
|
23
|
-
expect(Resque::Job.included_modules).to include(Appsignal::Integrations::ResqueIntegration)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::SequelHook do
|
2
|
-
if DependencyHelper.sequel_present?
|
3
|
-
let(:db) do
|
4
|
-
if DependencyHelper.running_jruby?
|
5
|
-
Sequel.connect("jdbc:sqlite::memory:")
|
6
|
-
else
|
7
|
-
Sequel.sqlite
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
before { start_agent }
|
12
|
-
|
13
|
-
describe "#dependencies_present?" do
|
14
|
-
subject { described_class.new.dependencies_present? }
|
15
|
-
|
16
|
-
it { is_expected.to be_truthy }
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with a transaction" do
|
20
|
-
let(:transaction) { http_request_transaction }
|
21
|
-
before do
|
22
|
-
set_current_transaction(transaction)
|
23
|
-
db.logger = Logger.new($stdout) # To test #log_duration call
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should instrument queries" do
|
27
|
-
expect(transaction).to receive(:start_event).at_least(:once)
|
28
|
-
expect(transaction).to receive(:finish_event)
|
29
|
-
.at_least(:once)
|
30
|
-
.with("sql.sequel", nil, kind_of(String), 1)
|
31
|
-
|
32
|
-
expect(db).to receive(:log_duration).at_least(:once)
|
33
|
-
|
34
|
-
db["SELECT 1"].all.to_a
|
35
|
-
end
|
36
|
-
end
|
37
|
-
else
|
38
|
-
describe "#dependencies_present?" do
|
39
|
-
subject { described_class.new.dependencies_present? }
|
40
|
-
|
41
|
-
it { is_expected.to be_falsy }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::ShoryukenHook do
|
2
|
-
context "with shoryuken" do
|
3
|
-
before(:context) do
|
4
|
-
module Shoryuken
|
5
|
-
def self.configure_server
|
6
|
-
end
|
7
|
-
end
|
8
|
-
Appsignal::Hooks::ShoryukenHook.new.install
|
9
|
-
end
|
10
|
-
|
11
|
-
after(:context) do
|
12
|
-
Object.send(:remove_const, :Shoryuken)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#dependencies_present?" do
|
16
|
-
subject { described_class.new.dependencies_present? }
|
17
|
-
|
18
|
-
it { is_expected.to be_truthy }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "without shoryuken" do
|
23
|
-
describe "#dependencies_present?" do
|
24
|
-
subject { described_class.new.dependencies_present? }
|
25
|
-
|
26
|
-
it { is_expected.to be_falsy }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|