appsignal 4.0.6-java → 4.0.7-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -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
- 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,193 +0,0 @@
|
|
1
|
-
class MockFormatter < Appsignal::EventFormatter
|
2
|
-
attr_reader :body
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
super
|
6
|
-
@body = "some value"
|
7
|
-
end
|
8
|
-
|
9
|
-
def format(_payload)
|
10
|
-
["title", body]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class MockFormatterDouble < MockFormatter
|
15
|
-
end
|
16
|
-
|
17
|
-
class MissingFormatMockFormatter
|
18
|
-
end
|
19
|
-
|
20
|
-
class IncorrectFormatMockFormatter < Appsignal::EventFormatter
|
21
|
-
def format
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class IncorrectFormatMock2Formatter < Appsignal::EventFormatter
|
26
|
-
def format(_payload, _foo = nil)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class MockDependentFormatter < Appsignal::EventFormatter
|
31
|
-
def initialize
|
32
|
-
super
|
33
|
-
raise "There is an error"
|
34
|
-
end
|
35
|
-
|
36
|
-
def format(_payload)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe Appsignal::EventFormatter do
|
41
|
-
let(:klass) { described_class }
|
42
|
-
around do |example|
|
43
|
-
original_formatters = described_class.formatters
|
44
|
-
example.run
|
45
|
-
described_class.class_variable_set(:@@formatters, original_formatters)
|
46
|
-
end
|
47
|
-
|
48
|
-
describe ".register" do
|
49
|
-
it "registers a formatter" do
|
50
|
-
expect(klass.registered?("mock")).to be_falsy
|
51
|
-
|
52
|
-
klass.register "mock", MockFormatter
|
53
|
-
|
54
|
-
expect(klass.formatters["mock"]).to be_instance_of(MockFormatter)
|
55
|
-
expect(klass.formatter_classes["mock"]).to eq MockFormatter
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when a formatter with the name already exists" do
|
59
|
-
it "does not register the formatter again" do
|
60
|
-
logs = capture_logs do
|
61
|
-
klass.register("mock.twice", MockFormatter)
|
62
|
-
klass.register("mock.twice", MockFormatter)
|
63
|
-
end
|
64
|
-
expect(klass.registered?("mock.twice")).to be_truthy
|
65
|
-
expect(logs).to contains_log :warn,
|
66
|
-
"Formatter for 'mock.twice' already registered, not registering 'MockFormatter'"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when there is an error initializing the formatter" do
|
71
|
-
it "does not register the formatter and logs an error" do
|
72
|
-
logs = capture_logs do
|
73
|
-
described_class.register "mock.dependent", MockDependentFormatter
|
74
|
-
end
|
75
|
-
expect(klass.registered?("mock.dependent")).to be_falsy
|
76
|
-
expect(logs).to contains_log :error,
|
77
|
-
"'There is an error' " \
|
78
|
-
"when initializing mock.dependent event formatter"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "when formatter has no format/1 method" do
|
83
|
-
context "when the formatter has no format method" do
|
84
|
-
it "does not register the formatter and logs an error" do
|
85
|
-
logs = capture_logs do
|
86
|
-
described_class.register "mock.missing", MissingFormatMockFormatter
|
87
|
-
end
|
88
|
-
expect(klass.registered?("mock.missing")).to be_falsy
|
89
|
-
expect(logs).to contains_log :error,
|
90
|
-
"'MissingFormatMockFormatter does not have a format(payload) " \
|
91
|
-
"method' when initializing mock.missing event formatter"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "when the formatter has an format/0 method" do
|
96
|
-
it "does not register the formatter and logs an error" do
|
97
|
-
logs = capture_logs do
|
98
|
-
described_class.register "mock.incorrect", IncorrectFormatMockFormatter
|
99
|
-
end
|
100
|
-
expect(klass.registered?("mock.incorrect")).to be_falsy
|
101
|
-
expect(logs).to contains_log :error,
|
102
|
-
"'IncorrectFormatMockFormatter does not have a format(payload) " \
|
103
|
-
"method' when initializing mock.incorrect event formatter"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when formatter has an format/2 method" do
|
108
|
-
it "does not register the formatter and logs an error" do
|
109
|
-
logs = capture_logs do
|
110
|
-
described_class.register "mock.incorrect", IncorrectFormatMock2Formatter
|
111
|
-
end
|
112
|
-
expect(klass.registered?("mock.incorrect")).to be_falsy
|
113
|
-
expect(logs).to contains_log :error,
|
114
|
-
"'IncorrectFormatMock2Formatter does not have a format(payload) " \
|
115
|
-
"method' when initializing mock.incorrect event formatter"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe ".registered?" do
|
122
|
-
context "when checking by name" do
|
123
|
-
context "when there is a formatter with that name" do
|
124
|
-
it "returns true" do
|
125
|
-
klass.register "mock", MockFormatter
|
126
|
-
expect(klass.registered?("mock")).to be_truthy
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "when there is no formatter with that name" do
|
131
|
-
it "returns false" do
|
132
|
-
expect(klass.registered?("nonsense")).to be_falsy
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "when checking by name and class" do
|
138
|
-
context "when there is a formatter with that name and class" do
|
139
|
-
it "returns true" do
|
140
|
-
klass.register "mock", MockFormatter
|
141
|
-
expect(klass.registered?("mock", MockFormatter)).to be_truthy
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when there is no formatter with that name and class" do
|
146
|
-
it "returns false" do
|
147
|
-
klass.register "mock", MockFormatterDouble
|
148
|
-
expect(klass.registered?("mock", MockFormatter)).to be_falsy
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe ".unregister" do
|
155
|
-
context "when a formatter with the name is registered" do
|
156
|
-
it "unregisters the formatter has the same class" do
|
157
|
-
klass.register("mock.unregister", MockFormatter)
|
158
|
-
expect(klass.registered?("mock.unregister")).to be_truthy
|
159
|
-
|
160
|
-
klass.unregister("mock.unregister", Hash)
|
161
|
-
expect(klass.registered?("mock.unregister")).to be_truthy
|
162
|
-
|
163
|
-
klass.unregister("mock.unregister", MockFormatter)
|
164
|
-
expect(klass.registered?("mock.unregister")).to be_falsy
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context "when a formatter with the same name and class is not registered" do
|
169
|
-
it "unregisters nothing" do
|
170
|
-
expect do
|
171
|
-
expect do
|
172
|
-
klass.unregister("nonse.unregister", MockFormatter)
|
173
|
-
end.to_not(change { klass.formatters })
|
174
|
-
end.to_not(change { klass.formatter_classes })
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe ".format" do
|
180
|
-
context "when no formatter with the name is registered" do
|
181
|
-
it "returns nil" do
|
182
|
-
expect(klass.format("nonsense", {})).to be_nil
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
context "when a formatter with the name is registered" do
|
187
|
-
it "calls the formatter and use a value set in the initializer" do
|
188
|
-
klass.register "mock", MockFormatter
|
189
|
-
expect(klass.format("mock", {})).to eq ["title", "some value"]
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
describe "JRuby extension", :jruby do
|
2
|
-
let(:extension) { Appsignal::Extension }
|
3
|
-
let(:jruby_module) { Appsignal::Extension::Jruby }
|
4
|
-
|
5
|
-
it "creates a JRuby extension module" do
|
6
|
-
expect(Appsignal::Extension::Jruby).to be_kind_of(Module)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "string conversions" do
|
10
|
-
it "keeps the same value during string type conversions" do
|
11
|
-
# UTF-8 string with NULL
|
12
|
-
# Tests if the conversions between the conversions without breaking on
|
13
|
-
# NULL terminated strings in C.
|
14
|
-
string = "Merry Christmas! \u0000 🎄"
|
15
|
-
|
16
|
-
appsignal_string = extension.make_appsignal_string(string)
|
17
|
-
ruby_string = extension.make_ruby_string(appsignal_string)
|
18
|
-
|
19
|
-
expect(ruby_string).to eq("Merry Christmas! \u0000 🎄")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it "loads libappsignal with FFI" do
|
24
|
-
expect(jruby_module.ffi_libraries.map(&:name).first).to include "libappsignal"
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".lib_extension" do
|
28
|
-
subject { jruby_module.lib_extension }
|
29
|
-
|
30
|
-
context "when on a darwin system" do
|
31
|
-
before { expect(Appsignal::System).to receive(:agent_platform).and_return("darwin") }
|
32
|
-
|
33
|
-
it "returns the extension for darwin" do
|
34
|
-
is_expected.to eq "dylib"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when on a linux system" do
|
39
|
-
before { expect(Appsignal::System).to receive(:agent_platform).and_return("linux") }
|
40
|
-
|
41
|
-
it "returns the lib extension for linux" do
|
42
|
-
is_expected.to eq "so"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
describe Appsignal::Extension, :extension_installation_failure do
|
2
|
-
context "when the extension library cannot be loaded" do
|
3
|
-
it "prints and logs an error" do
|
4
|
-
require "open3"
|
5
|
-
_stdout, stderr, _status = Open3.capture3("bin/appsignal --version")
|
6
|
-
expect(stderr).to include("ERROR: AppSignal failed to load extension")
|
7
|
-
error_message =
|
8
|
-
if DependencyHelper.running_jruby?
|
9
|
-
if DependencyHelper.macos?
|
10
|
-
"Could not open library"
|
11
|
-
else
|
12
|
-
"cannot open shared object file"
|
13
|
-
end
|
14
|
-
else
|
15
|
-
"LoadError: cannot load such file"
|
16
|
-
end
|
17
|
-
expect(stderr).to include(error_message)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
describe Appsignal::Extension do
|
2
|
-
describe ".agent_config" do
|
3
|
-
subject { Appsignal::Extension.agent_config }
|
4
|
-
|
5
|
-
it { is_expected.to have_key("version") }
|
6
|
-
it { is_expected.to have_key("triples") }
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".agent_version" do
|
10
|
-
subject { Appsignal::Extension.agent_version }
|
11
|
-
|
12
|
-
it { is_expected.to be_kind_of(String) }
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when the extension library can be loaded" do
|
16
|
-
subject { Appsignal::Extension }
|
17
|
-
|
18
|
-
it "should indicate that the extension is loaded" do
|
19
|
-
expect(Appsignal.extension_loaded?).to be_truthy
|
20
|
-
end
|
21
|
-
|
22
|
-
context "without valid config" do
|
23
|
-
let(:out_stream) { std_stream }
|
24
|
-
let(:output) { out_stream.read }
|
25
|
-
|
26
|
-
describe ".start" do
|
27
|
-
it "outputs a warning about not starting the extension" do
|
28
|
-
capture_std_streams(out_stream, out_stream) do
|
29
|
-
subject.start
|
30
|
-
end
|
31
|
-
|
32
|
-
expect(output).to match \
|
33
|
-
%r{
|
34
|
-
WARNING:\sError\swhen\sreading\sappsignal\sconfig,\s
|
35
|
-
appsignal\s\(as\s(\d{2,4})/(\d{2,4})\)\snot\sstarting
|
36
|
-
}x
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe ".stop" do
|
41
|
-
it "does nothing" do
|
42
|
-
capture_std_streams(out_stream, out_stream) do
|
43
|
-
subject.stop
|
44
|
-
end
|
45
|
-
expect(output).to be_empty
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with a valid config" do
|
51
|
-
before do
|
52
|
-
build_config.write_to_environment
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should have a start and stop method" do
|
56
|
-
subject.start
|
57
|
-
subject.stop
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with a transaction" do
|
61
|
-
subject { Appsignal::Extension.start_transaction("request_id", "http_request", 0) }
|
62
|
-
|
63
|
-
it "should have a start_event method" do
|
64
|
-
subject.start_event(0)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should have a finish_event method" do
|
68
|
-
subject.finish_event("name", "title", "body", 0, 0)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should have a record_event method" do
|
72
|
-
subject.record_event("name", "title", "body", 0, 1000, 1000)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should have a set_error method" do
|
76
|
-
subject.set_error("name", "message", Appsignal::Extension.data_map_new)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should have a set_sample_data method" do
|
80
|
-
subject.set_sample_data("params", Appsignal::Extension.data_map_new)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should have a set_action method" do
|
84
|
-
subject.set_action("value")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should have a set_namespace method" do
|
88
|
-
subject.set_namespace("value")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should have a set_queue_start method" do
|
92
|
-
subject.set_queue_start(10)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should have a set_metadata method" do
|
96
|
-
subject.set_metadata("key", "value")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should have a finish method" do
|
100
|
-
subject.finish(0)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should have a duplicate method" do
|
104
|
-
subject.duplicate("request_id")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should have a complete method" do
|
108
|
-
subject.complete
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should have a set_gauge method" do
|
113
|
-
subject.set_gauge("key", 1.0, Appsignal::Extension.data_map_new)
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should have a increment_counter method" do
|
117
|
-
subject.increment_counter("key", 1.0, Appsignal::Extension.data_map_new)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should have a add_distribution_value method" do
|
121
|
-
subject.add_distribution_value("key", 1.0, Appsignal::Extension.data_map_new)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "when the extension library cannot be loaded", :extension_installation_failure do
|
127
|
-
let(:ext) { Appsignal::Extension }
|
128
|
-
|
129
|
-
around do |example|
|
130
|
-
Appsignal::Testing.without_testing { example.run }
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should indicate that the extension is not loaded" do
|
134
|
-
expect(Appsignal.extension_loaded?).to be_falsy
|
135
|
-
end
|
136
|
-
|
137
|
-
it "does not raise errors when methods are called" do
|
138
|
-
ext.appsignal_start
|
139
|
-
ext.something
|
140
|
-
end
|
141
|
-
|
142
|
-
describe Appsignal::Extension::MockData do
|
143
|
-
it "does not error on missing data_map_new extension method calls" do
|
144
|
-
map = ext.data_map_new
|
145
|
-
expect(map).to be_kind_of(Appsignal::Extension::MockData)
|
146
|
-
# Does not raise errors any arbitrary method call that does not exist
|
147
|
-
map.set_string("key", "value")
|
148
|
-
map.set_int("key", 123)
|
149
|
-
map.something
|
150
|
-
end
|
151
|
-
|
152
|
-
it "does not error on missing data_array_new extension method calls" do
|
153
|
-
array = ext.data_array_new
|
154
|
-
expect(array).to be_kind_of(Appsignal::Extension::MockData)
|
155
|
-
# Does not raise errors any arbitrary method call that does not exist
|
156
|
-
array.append_string("value")
|
157
|
-
array.append_int(123)
|
158
|
-
array.something
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe Appsignal::Extension::MockTransaction do
|
163
|
-
it "does not error on missing transaction extension method calls" do
|
164
|
-
transaction = described_class.new
|
165
|
-
|
166
|
-
transaction.start_event(0)
|
167
|
-
transaction.finish_event(
|
168
|
-
"name",
|
169
|
-
"title",
|
170
|
-
"body",
|
171
|
-
Appsignal::EventFormatter::DEFAULT,
|
172
|
-
0
|
173
|
-
)
|
174
|
-
transaction.something
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
describe Appsignal::GarbageCollection do
|
2
|
-
describe ".profiler" do
|
3
|
-
before do
|
4
|
-
# Unset the internal memoized variable to avoid state leaking
|
5
|
-
described_class.clear_profiler!
|
6
|
-
end
|
7
|
-
|
8
|
-
context "when GC instrumentation is disabled" do
|
9
|
-
it "returns the NilProfiler" do
|
10
|
-
expect(described_class.profiler).to be_a(Appsignal::GarbageCollection::NilProfiler)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when GC profiling is enabled" do
|
15
|
-
before { GC::Profiler.enable }
|
16
|
-
after { GC::Profiler.disable }
|
17
|
-
|
18
|
-
it "returns the Profiler" do
|
19
|
-
expect(described_class.profiler).to be_a(Appsignal::GarbageCollection::Profiler)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe Appsignal::GarbageCollection::Profiler do
|
26
|
-
let(:internal_profiler) { FakeGCProfiler.new }
|
27
|
-
let(:profiler) { described_class.new }
|
28
|
-
|
29
|
-
before do
|
30
|
-
stub_const("GC::Profiler", internal_profiler)
|
31
|
-
end
|
32
|
-
|
33
|
-
context "on initialization" do
|
34
|
-
it "has a total time of 0" do
|
35
|
-
expect(profiler.total_time).to eq(0)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "when the GC has run" do
|
40
|
-
before { internal_profiler.total_time = 0.12345 }
|
41
|
-
|
42
|
-
it "fetches the total time from Ruby's GC::Profiler" do
|
43
|
-
expect(profiler.total_time).to eq(123)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "clears Ruby's GC::Profiler afterward" do
|
47
|
-
expect(internal_profiler).to receive(:clear)
|
48
|
-
profiler.total_time
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when the total GC time becomes too high" do
|
53
|
-
it "resets the total time" do
|
54
|
-
internal_profiler.total_time = 2_147_483_647
|
55
|
-
expect(profiler.total_time).to eq(0)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when the GC has run multiple times" do
|
60
|
-
it "adds all times from Ruby's GC::Profiler together" do
|
61
|
-
2.times do
|
62
|
-
internal_profiler.total_time = 0.12345
|
63
|
-
profiler.total_time
|
64
|
-
end
|
65
|
-
|
66
|
-
expect(profiler.total_time).to eq(246)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when in multiple threads and with a slow GC::Profiler" do
|
71
|
-
it "does not count garbage collection times twice" do
|
72
|
-
threads = []
|
73
|
-
results = []
|
74
|
-
internal_profiler.clear_delay = 0.001
|
75
|
-
internal_profiler.total_time = 0.12345
|
76
|
-
|
77
|
-
2.times do
|
78
|
-
threads << Thread.new do
|
79
|
-
profiler = Appsignal::GarbageCollection::Profiler.new
|
80
|
-
results << profiler.total_time
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
threads.each(&:join)
|
85
|
-
expect(results).to eq([123, 0])
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe Appsignal::GarbageCollection::NilProfiler do
|
91
|
-
let(:profiler) { described_class.new }
|
92
|
-
|
93
|
-
describe "#total_time" do
|
94
|
-
it "has a total time of 0" do
|
95
|
-
expect(profiler.total_time).to eq(0)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|