appsignal 4.0.6 → 4.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Rakefile +9 -9
- data/appsignal.gemspec +22 -1
- data/ext/agent.rb +27 -27
- data/lib/appsignal/check_in.rb +1 -1
- data/lib/appsignal/config.rb +1 -3
- data/lib/appsignal/integrations/resque.rb +1 -6
- data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +10 -8
- metadata +2 -192
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/chore.md +0 -14
- data/.github/workflows/ci.yml +0 -3285
- 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-1.gemfile +0 -5
- data/gemfiles/que-2.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 -210
- data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
- 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 -187
- 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 -414
- 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 -2115
- 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 -179
- 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 -60
- 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 -155
- 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 -203
- data/support/bundler_wrapper +0 -12
- data/support/install_deps +0 -33
@@ -1,105 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::AtExit do
|
2
|
-
describe ".install" do
|
3
|
-
before { start_agent(:options => options) }
|
4
|
-
|
5
|
-
context "with :enable_at_exit_reporter == true" do
|
6
|
-
let(:options) { { :enable_at_exit_reporter => true } }
|
7
|
-
|
8
|
-
it "installs the at_exit hook" do
|
9
|
-
expect(Appsignal::Hooks::AtExit::AtExitCallback).to receive(:call)
|
10
|
-
|
11
|
-
expect(Kernel).to receive(:at_exit).with(no_args) do |*_args, &block|
|
12
|
-
block.call
|
13
|
-
end
|
14
|
-
|
15
|
-
described_class.new.install
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with :enable_at_exit_reporter == false" do
|
20
|
-
let(:options) { { :enable_at_exit_reporter => false } }
|
21
|
-
|
22
|
-
it "doesn't install the at_exit hook" do
|
23
|
-
expect(Kernel).to_not receive(:at_exit)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe Appsignal::Hooks::AtExit::AtExitCallback do
|
30
|
-
around { |example| keep_transactions { example.run } }
|
31
|
-
before { start_agent(:options => { :enable_at_exit_reporter => true }) }
|
32
|
-
|
33
|
-
def with_error(error_class, error_message)
|
34
|
-
raise error_class, error_message
|
35
|
-
rescue error_class => error
|
36
|
-
yield error
|
37
|
-
end
|
38
|
-
|
39
|
-
def call_callback
|
40
|
-
Appsignal::Hooks::AtExit::AtExitCallback.call
|
41
|
-
end
|
42
|
-
|
43
|
-
it "reports no transaction if the process didn't exit with an error" do
|
44
|
-
logs =
|
45
|
-
capture_logs do
|
46
|
-
expect do
|
47
|
-
call_callback
|
48
|
-
end.to_not(change { created_transactions.count })
|
49
|
-
end
|
50
|
-
|
51
|
-
expect(logs).to_not contains_log(:error, "Appsignal.report_error: Cannot add error.")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "reports an error if there's an unhandled error" do
|
55
|
-
expect do
|
56
|
-
with_error(ExampleException, "error message") do
|
57
|
-
call_callback
|
58
|
-
end
|
59
|
-
end.to change { created_transactions.count }.by(1)
|
60
|
-
|
61
|
-
transaction = last_transaction
|
62
|
-
expect(transaction).to have_namespace("unhandled")
|
63
|
-
expect(transaction).to have_error("ExampleException", "error message")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "calls Appsignal.stop" do
|
67
|
-
expect(Appsignal).to receive(:stop).with("at_exit")
|
68
|
-
with_error(ExampleException, "error message") do
|
69
|
-
call_callback
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it "doesn't report the error if it is also the last error reported" do
|
74
|
-
with_error(ExampleException, "error message") do |error|
|
75
|
-
Appsignal.report_error(error)
|
76
|
-
expect(created_transactions.count).to eq(1)
|
77
|
-
|
78
|
-
expect do
|
79
|
-
call_callback
|
80
|
-
end.to_not change { created_transactions.count }.from(1)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
it "doesn't report the error if it is a SystemExit exception" do
|
85
|
-
with_error(SystemExit, "error message") do |error|
|
86
|
-
Appsignal.report_error(error)
|
87
|
-
expect(created_transactions.count).to eq(1)
|
88
|
-
|
89
|
-
expect do
|
90
|
-
call_callback
|
91
|
-
end.to_not change { created_transactions.count }.from(1)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
it "doesn't report the error if it is a SignalException exception" do
|
96
|
-
with_error(SignalException, "TERM") do |error|
|
97
|
-
Appsignal.report_error(error)
|
98
|
-
expect(created_transactions.count).to eq(1)
|
99
|
-
|
100
|
-
expect do
|
101
|
-
call_callback
|
102
|
-
end.to_not change { created_transactions.count }.from(1)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::CelluloidHook do
|
2
|
-
context "with celluloid" do
|
3
|
-
before :context do
|
4
|
-
module Celluloid
|
5
|
-
def self.shutdown
|
6
|
-
@shut_down = true
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.shut_down?
|
10
|
-
@shut_down == true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
Appsignal::Hooks::CelluloidHook.new.install
|
14
|
-
end
|
15
|
-
after :context do
|
16
|
-
Object.send(:remove_const, :Celluloid)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#dependencies_present?" do
|
20
|
-
subject { described_class.new.dependencies_present? }
|
21
|
-
|
22
|
-
it { is_expected.to be_truthy }
|
23
|
-
end
|
24
|
-
|
25
|
-
specify { expect(Appsignal).to receive(:stop) }
|
26
|
-
specify { expect(Celluloid.shut_down?).to be true }
|
27
|
-
|
28
|
-
after do
|
29
|
-
Celluloid.shutdown
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "without celluloid" do
|
34
|
-
describe "#dependencies_present?" do
|
35
|
-
subject { described_class.new.dependencies_present? }
|
36
|
-
|
37
|
-
it { is_expected.to be_falsy }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::DataMapperHook do
|
2
|
-
context "with datamapper" do
|
3
|
-
before :context do
|
4
|
-
module DataMapper
|
5
|
-
end
|
6
|
-
|
7
|
-
module DataObjects
|
8
|
-
class Connection
|
9
|
-
end
|
10
|
-
end
|
11
|
-
Appsignal::Hooks::DataMapperHook.new.install
|
12
|
-
end
|
13
|
-
|
14
|
-
after :context do
|
15
|
-
Object.send(:remove_const, :DataMapper)
|
16
|
-
Object.send(:remove_const, :DataObjects)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#dependencies_present?" do
|
20
|
-
subject { described_class.new.dependencies_present? }
|
21
|
-
|
22
|
-
it { is_expected.to be_truthy }
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should install the listener" do
|
26
|
-
expect(::DataObjects::Connection).to receive(:include)
|
27
|
-
.with(Appsignal::Hooks::DataMapperLogListener)
|
28
|
-
|
29
|
-
Appsignal::Hooks::DataMapperHook.new.install
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "without datamapper" do
|
34
|
-
describe "#dependencies_present?" do
|
35
|
-
subject { described_class.new.dependencies_present? }
|
36
|
-
|
37
|
-
it { is_expected.to be_falsy }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::DelayedJobHook do
|
2
|
-
context "with delayed job" do
|
3
|
-
before(:context) do
|
4
|
-
module Delayed
|
5
|
-
class Plugin
|
6
|
-
def self.callbacks
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class Worker
|
11
|
-
def self.plugins
|
12
|
-
@plugins ||= []
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
after(:context) { Object.send(:remove_const, :Delayed) }
|
18
|
-
before { start_agent }
|
19
|
-
|
20
|
-
describe "#dependencies_present?" do
|
21
|
-
subject { described_class.new.dependencies_present? }
|
22
|
-
|
23
|
-
it { is_expected.to be_truthy }
|
24
|
-
end
|
25
|
-
|
26
|
-
it "adds the plugin" do
|
27
|
-
expect(::Delayed::Worker.plugins).to include(Appsignal::Integrations::DelayedJobPlugin)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "without delayed job" do
|
32
|
-
describe "#dependencies_present?" do
|
33
|
-
subject { described_class.new.dependencies_present? }
|
34
|
-
|
35
|
-
it { is_expected.to be_falsy }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if DependencyHelper.dry_monitor_present?
|
4
|
-
require "dry-monitor"
|
5
|
-
|
6
|
-
describe Appsignal::Hooks::DryMonitorHook do
|
7
|
-
describe "#dependencies_present?" do
|
8
|
-
subject { described_class.new.dependencies_present? }
|
9
|
-
|
10
|
-
context "when Dry::Monitor::Notifications constant is found" do
|
11
|
-
before { stub_const "Dry::Monitor::Notifications", Class.new }
|
12
|
-
|
13
|
-
it { is_expected.to be_truthy }
|
14
|
-
end
|
15
|
-
|
16
|
-
context "when Dry::Monitor::Notifications constant is not found" do
|
17
|
-
before { hide_const "Dry::Monitor::Notifications" }
|
18
|
-
|
19
|
-
it { is_expected.to be_falsy }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#install" do
|
25
|
-
it "installs the dry-monitor hook" do
|
26
|
-
start_agent
|
27
|
-
|
28
|
-
expect(Dry::Monitor::Notifications.included_modules).to include(
|
29
|
-
Appsignal::Integrations::DryMonitorIntegration
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "Dry Monitor Integration" do
|
35
|
-
let(:notifications) { Dry::Monitor::Notifications.new(:test) }
|
36
|
-
let(:transaction) { http_request_transaction }
|
37
|
-
before do
|
38
|
-
start_agent
|
39
|
-
set_current_transaction(transaction)
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when is a dry-sql event" do
|
43
|
-
let(:event_id) { :sql }
|
44
|
-
let(:payload) do
|
45
|
-
{
|
46
|
-
:name => "postgres",
|
47
|
-
:query => "SELECT * FROM users"
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
it "creates an sql event" do
|
52
|
-
notifications.instrument(event_id, payload)
|
53
|
-
expect(transaction).to include_event(
|
54
|
-
"body" => "SELECT * FROM users",
|
55
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
56
|
-
"count" => 1,
|
57
|
-
"name" => "query.postgres",
|
58
|
-
"title" => "query.postgres"
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "when is an unregistered formatter event" do
|
64
|
-
let(:event_id) { :foo }
|
65
|
-
let(:payload) do
|
66
|
-
{
|
67
|
-
:name => "foo"
|
68
|
-
}
|
69
|
-
end
|
70
|
-
|
71
|
-
it "creates a generic event" do
|
72
|
-
notifications.instrument(event_id, payload)
|
73
|
-
expect(transaction).to include_event(
|
74
|
-
"body" => "",
|
75
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
76
|
-
"count" => 1,
|
77
|
-
"name" => "foo",
|
78
|
-
"title" => ""
|
79
|
-
)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::ExconHook do
|
2
|
-
before { start_agent }
|
3
|
-
|
4
|
-
context "with Excon" do
|
5
|
-
before(:context) do
|
6
|
-
class Excon
|
7
|
-
def self.defaults
|
8
|
-
@defaults ||= {}
|
9
|
-
end
|
10
|
-
end
|
11
|
-
Appsignal::Hooks::ExconHook.new.install
|
12
|
-
end
|
13
|
-
after(:context) { Object.send(:remove_const, :Excon) }
|
14
|
-
|
15
|
-
describe "#dependencies_present?" do
|
16
|
-
subject { described_class.new.dependencies_present? }
|
17
|
-
|
18
|
-
it { is_expected.to be_truthy }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#install" do
|
22
|
-
it "adds the AppSignal instrumentor to Excon" do
|
23
|
-
expect(Excon.defaults[:instrumentor]).to eql(Appsignal::Integrations::ExconIntegration)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "instrumentation" do
|
28
|
-
let(:transaction) { http_request_transaction }
|
29
|
-
before { set_current_transaction(transaction) }
|
30
|
-
around { |example| keep_transactions { example.run } }
|
31
|
-
|
32
|
-
it "instruments a http request" do
|
33
|
-
data = {
|
34
|
-
:host => "www.google.com",
|
35
|
-
:method => :get,
|
36
|
-
:scheme => "http"
|
37
|
-
}
|
38
|
-
Excon.defaults[:instrumentor].instrument("excon.request", data) {} # rubocop:disable Lint/EmptyBlock
|
39
|
-
|
40
|
-
expect(transaction).to include_event(
|
41
|
-
"name" => "request.excon",
|
42
|
-
"title" => "GET http://www.google.com",
|
43
|
-
"body" => ""
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "instruments a http response" do
|
48
|
-
data = { :host => "www.google.com" }
|
49
|
-
Excon.defaults[:instrumentor].instrument("excon.response", data) {} # rubocop:disable Lint/EmptyBlock
|
50
|
-
|
51
|
-
expect(transaction).to include_event(
|
52
|
-
"name" => "response.excon",
|
53
|
-
"title" => "www.google.com",
|
54
|
-
"body" => ""
|
55
|
-
)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "without Excon" do
|
61
|
-
describe "#dependencies_present?" do
|
62
|
-
subject { described_class.new.dependencies_present? }
|
63
|
-
|
64
|
-
it { is_expected.to be_falsy }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::GvlHook do
|
2
|
-
if DependencyHelper.running_jruby?
|
3
|
-
context "running JRuby" do
|
4
|
-
it "does not attempt to require GVLTools" do
|
5
|
-
expect_any_instance_of(described_class).not_to receive(:require).with("gvltools")
|
6
|
-
expect(described_class.new.dependencies_present?).to be_falsy
|
7
|
-
end
|
8
|
-
end
|
9
|
-
else
|
10
|
-
let(:options) { {} }
|
11
|
-
before do
|
12
|
-
start_agent(:options => options)
|
13
|
-
end
|
14
|
-
|
15
|
-
def expect_gvltools_require
|
16
|
-
expect_any_instance_of(described_class).to receive(:require).with("gvltools").and_return(true)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "without GVLTools" do
|
20
|
-
describe "#dependencies_present?" do
|
21
|
-
context "if requiring gvltools fails" do
|
22
|
-
it "is false" do
|
23
|
-
expect(described_class.new.dependencies_present?).to be_falsy
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is false" do
|
28
|
-
expect_gvltools_require
|
29
|
-
expect(described_class.new.dependencies_present?).to be_falsy
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "with old versions of GVLTools" do
|
35
|
-
before(:context) do
|
36
|
-
module GVLTools
|
37
|
-
VERSION = "0.1.0".freeze
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
after(:context) { Object.send(:remove_const, :GVLTools) }
|
42
|
-
|
43
|
-
before(:each) { expect_gvltools_require }
|
44
|
-
|
45
|
-
describe "#dependencies_present?" do
|
46
|
-
it "is false" do
|
47
|
-
expect(described_class.new.dependencies_present?).to be_falsy
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "with new versions of GVLTools" do
|
53
|
-
before(:context) do
|
54
|
-
module GVLTools
|
55
|
-
VERSION = "0.2.0".freeze
|
56
|
-
|
57
|
-
module GlobalTimer
|
58
|
-
def self.enable
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
module WaitingThreads
|
63
|
-
def self.enable
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
after(:context) { Object.send(:remove_const, :GVLTools) }
|
70
|
-
|
71
|
-
describe "#dependencies_present?" do
|
72
|
-
before(:each) { expect_gvltools_require }
|
73
|
-
|
74
|
-
if DependencyHelper.ruby_3_2_or_newer?
|
75
|
-
it "is true" do
|
76
|
-
expect(described_class.new.dependencies_present?).to be_truthy
|
77
|
-
end
|
78
|
-
else
|
79
|
-
it "is false" do
|
80
|
-
expect(described_class.new.dependencies_present?).to be_falsy
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
if DependencyHelper.ruby_3_2_or_newer?
|
86
|
-
describe "Appsignal::Hooks.load_hooks" do
|
87
|
-
before(:each) { expect_gvltools_require }
|
88
|
-
|
89
|
-
# After installing a hook once, it is marked as already installed,
|
90
|
-
# and subsequent calls to `load_hooks` silently do nothing.
|
91
|
-
# Because of this, only one of the tests for the installation uses
|
92
|
-
# `load_hooks`, while the rest call the `install` method directly.
|
93
|
-
|
94
|
-
it "is added to minutely probes" do
|
95
|
-
Appsignal::Hooks.load_hooks
|
96
|
-
|
97
|
-
expect(Appsignal::Probes.probes[:gvl]).to be Appsignal::Probes::GvlProbe
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#install" do
|
103
|
-
context "with enable_gvl_global_timer" do
|
104
|
-
let(:options) { { :enable_gvl_global_timer => true } }
|
105
|
-
|
106
|
-
it "enables the GVL global timer" do
|
107
|
-
expect(::GVLTools::GlobalTimer).to receive(:enable)
|
108
|
-
|
109
|
-
described_class.new.install
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "without enable_gvl_global_timer" do
|
114
|
-
let(:options) { { :enable_gvl_global_timer => false } }
|
115
|
-
|
116
|
-
it "does not enable the GVL global timer" do
|
117
|
-
expect(::GVLTools::GlobalTimer).not_to receive(:enable)
|
118
|
-
|
119
|
-
described_class.new.install
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "with enable_gvl_waiting_threads" do
|
124
|
-
let(:options) { { :enable_gvl_waiting_threads => true } }
|
125
|
-
|
126
|
-
it "enables the GVL waiting threads" do
|
127
|
-
expect(::GVLTools::WaitingThreads).to receive(:enable)
|
128
|
-
|
129
|
-
described_class.new.install
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "without enable_gvl_waiting_threads" do
|
134
|
-
let(:options) { { :enable_gvl_waiting_threads => false } }
|
135
|
-
|
136
|
-
it "does not enable the GVL waiting threads" do
|
137
|
-
expect(::GVLTools::WaitingThreads).not_to receive(:enable)
|
138
|
-
|
139
|
-
described_class.new.install
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Appsignal::Hooks::HttpHook do
|
4
|
-
let(:options) { {} }
|
5
|
-
before { start_agent(:options => options) }
|
6
|
-
|
7
|
-
if DependencyHelper.http_present?
|
8
|
-
context "with instrument_http_rb set to true" do
|
9
|
-
describe "#dependencies_present?" do
|
10
|
-
subject { described_class.new.dependencies_present? }
|
11
|
-
|
12
|
-
it { is_expected.to be_truthy }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "installs the HTTP plugin" do
|
16
|
-
expect(HTTP::Client.included_modules)
|
17
|
-
.to include(Appsignal::Integrations::HttpIntegration)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "with instrument_http_rb set to false" do
|
22
|
-
let(:options) { { :instrument_http_rb => false } }
|
23
|
-
|
24
|
-
describe "#dependencies_present?" do
|
25
|
-
subject { described_class.new.dependencies_present? }
|
26
|
-
|
27
|
-
it { is_expected.to be_falsy }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
else
|
31
|
-
describe "#dependencies_present?" do
|
32
|
-
subject { described_class.new.dependencies_present? }
|
33
|
-
|
34
|
-
it { is_expected.to be_falsy }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::MongoRubyDriverHook do
|
2
|
-
require "appsignal/integrations/mongo_ruby_driver"
|
3
|
-
|
4
|
-
context "with mongo ruby driver" do
|
5
|
-
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
6
|
-
before do
|
7
|
-
allow(Appsignal::Hooks::MongoMonitorSubscriber).to receive(:new).and_return(subscriber)
|
8
|
-
end
|
9
|
-
|
10
|
-
before(:context) do
|
11
|
-
module Mongo
|
12
|
-
module Monitoring
|
13
|
-
COMMAND = "command".freeze
|
14
|
-
|
15
|
-
class Global
|
16
|
-
def subscribe
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
after(:context) { Object.send(:remove_const, :Mongo) }
|
23
|
-
|
24
|
-
describe "#dependencies_present?" do
|
25
|
-
subject { described_class.new.dependencies_present? }
|
26
|
-
|
27
|
-
it { is_expected.to be_truthy }
|
28
|
-
end
|
29
|
-
|
30
|
-
it "adds a subscriber to Mongo::Monitoring" do
|
31
|
-
expect(Mongo::Monitoring::Global).to receive(:subscribe)
|
32
|
-
.with("command", subscriber)
|
33
|
-
.at_least(:once)
|
34
|
-
|
35
|
-
Appsignal::Hooks::MongoRubyDriverHook.new.install
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "without mongo ruby driver" do
|
40
|
-
describe "#dependencies_present?" do
|
41
|
-
subject { described_class.new.dependencies_present? }
|
42
|
-
|
43
|
-
it { is_expected.to be_falsy }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::MriHook do
|
2
|
-
describe "#dependencies_present?" do
|
3
|
-
subject { described_class.new.dependencies_present? }
|
4
|
-
|
5
|
-
if DependencyHelper.running_jruby?
|
6
|
-
it { is_expected.to be_falsy }
|
7
|
-
else
|
8
|
-
it { is_expected.to be_truthy }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
unless DependencyHelper.running_jruby?
|
13
|
-
context "install" do
|
14
|
-
before do
|
15
|
-
Appsignal::Hooks.load_hooks
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be added to minutely probes" do
|
19
|
-
expect(Appsignal::Probes.probes[:mri]).to be Appsignal::Probes::MriProbe
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::NetHttpHook do
|
2
|
-
let(:options) { {} }
|
3
|
-
before { start_agent(:options => options) }
|
4
|
-
|
5
|
-
describe "#dependencies_present?" do
|
6
|
-
subject { described_class.new.dependencies_present? }
|
7
|
-
|
8
|
-
context "with Net::HTTP instrumentation enabled" do
|
9
|
-
it { is_expected.to be_truthy }
|
10
|
-
end
|
11
|
-
|
12
|
-
context "with Net::HTTP instrumentation disabled" do
|
13
|
-
let(:options) { { :instrument_net_http => false } }
|
14
|
-
|
15
|
-
it { is_expected.to be_falsy }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::PassengerHook do
|
2
|
-
context "with passenger" do
|
3
|
-
before(:context) do
|
4
|
-
module PhusionPassenger
|
5
|
-
end
|
6
|
-
end
|
7
|
-
after(:context) { Object.send(:remove_const, :PhusionPassenger) }
|
8
|
-
|
9
|
-
describe "#dependencies_present?" do
|
10
|
-
subject { described_class.new.dependencies_present? }
|
11
|
-
|
12
|
-
it { is_expected.to be_truthy }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "adds behavior to stopping_worker_process and starting_worker_process" do
|
16
|
-
expect(PhusionPassenger).to receive(:on_event).with(:starting_worker_process)
|
17
|
-
expect(PhusionPassenger).to receive(:on_event).with(:stopping_worker_process)
|
18
|
-
|
19
|
-
Appsignal::Hooks::PassengerHook.new.install
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "without passenger" do
|
24
|
-
describe "#dependencies_present?" do
|
25
|
-
subject { described_class.new.dependencies_present? }
|
26
|
-
|
27
|
-
it { is_expected.to be_falsy }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|