appsignal 4.0.6-java → 4.0.7-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/ext/agent.rb +27 -27
  6. data/lib/appsignal/check_in.rb +1 -1
  7. data/lib/appsignal/config.rb +1 -3
  8. data/lib/appsignal/integrations/resque.rb +1 -6
  9. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  10. data/lib/appsignal/version.rb +1 -1
  11. metadata +2 -192
  12. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  13. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  14. data/.github/workflows/ci.yml +0 -3285
  15. data/.github/workflows/create_release_from_tag.yml +0 -62
  16. data/.gitignore +0 -35
  17. data/.gitmodules +0 -3
  18. data/.rspec +0 -4
  19. data/.yardopts +0 -8
  20. data/benchmark.rake +0 -139
  21. data/gemfiles/capistrano2.gemfile +0 -6
  22. data/gemfiles/capistrano3.gemfile +0 -7
  23. data/gemfiles/dry-monitor.gemfile +0 -5
  24. data/gemfiles/grape.gemfile +0 -5
  25. data/gemfiles/hanami-2.0.gemfile +0 -7
  26. data/gemfiles/hanami-2.1.gemfile +0 -7
  27. data/gemfiles/http5.gemfile +0 -5
  28. data/gemfiles/no_dependencies.gemfile +0 -10
  29. data/gemfiles/padrino.gemfile +0 -7
  30. data/gemfiles/psych-3.gemfile +0 -5
  31. data/gemfiles/psych-4.gemfile +0 -5
  32. data/gemfiles/que-1.gemfile +0 -5
  33. data/gemfiles/que-2.gemfile +0 -5
  34. data/gemfiles/rails-6.0.gemfile +0 -10
  35. data/gemfiles/rails-6.1.gemfile +0 -11
  36. data/gemfiles/rails-7.0.gemfile +0 -11
  37. data/gemfiles/rails-7.1.gemfile +0 -11
  38. data/gemfiles/rails-7.2.gemfile +0 -11
  39. data/gemfiles/redis-4.gemfile +0 -5
  40. data/gemfiles/redis-5.gemfile +0 -6
  41. data/gemfiles/resque-2.gemfile +0 -6
  42. data/gemfiles/sequel.gemfile +0 -10
  43. data/gemfiles/sinatra.gemfile +0 -5
  44. data/gemfiles/webmachine1.gemfile +0 -7
  45. data/gemfiles/webmachine2.gemfile +0 -6
  46. data/mono.yml +0 -16
  47. data/spec/.rubocop.yml +0 -7
  48. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  49. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  50. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  51. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -210
  52. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
  53. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  54. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  55. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  56. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  57. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  58. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  59. data/spec/lib/appsignal/cli_spec.rb +0 -56
  60. data/spec/lib/appsignal/config_spec.rb +0 -1380
  61. data/spec/lib/appsignal/demo_spec.rb +0 -83
  62. data/spec/lib/appsignal/environment_spec.rb +0 -190
  63. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  64. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  65. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  66. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  67. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  69. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  70. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  71. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  72. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  73. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  74. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  75. data/spec/lib/appsignal/extension_spec.rb +0 -178
  76. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  77. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  78. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  79. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  80. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  81. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  82. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  83. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  84. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  85. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  86. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  87. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  88. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  89. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  90. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  91. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  92. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  93. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  94. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  95. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  96. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  97. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  98. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  99. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  100. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  101. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  102. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  103. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  104. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  105. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  106. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  107. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  108. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  109. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  110. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  111. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  112. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  113. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  114. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  115. data/spec/lib/appsignal/integrations/que_spec.rb +0 -187
  116. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  117. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  118. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  119. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  120. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  121. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  122. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  123. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  124. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  125. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  126. data/spec/lib/appsignal/logger_spec.rb +0 -205
  127. data/spec/lib/appsignal/marker_spec.rb +0 -51
  128. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  129. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  130. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  131. data/spec/lib/appsignal/probes_spec.rb +0 -414
  132. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  133. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  134. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  135. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  136. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  137. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  138. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  139. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  140. data/spec/lib/appsignal/rack_spec.rb +0 -243
  141. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  142. data/spec/lib/appsignal/span_spec.rb +0 -141
  143. data/spec/lib/appsignal/system_spec.rb +0 -126
  144. data/spec/lib/appsignal/transaction_spec.rb +0 -2115
  145. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  146. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  147. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  148. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  149. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  150. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  151. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  152. data/spec/lib/appsignal_spec.rb +0 -1919
  153. data/spec/lib/puma/appsignal_spec.rb +0 -334
  154. data/spec/spec_helper.rb +0 -179
  155. data/spec/support/fixtures/generated_config.yml +0 -24
  156. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  157. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  158. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  159. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  160. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  162. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  163. data/spec/support/fixtures/uploaded_file.txt +0 -0
  164. data/spec/support/hanami/hanami_app.rb +0 -29
  165. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  166. data/spec/support/helpers/activejob_helpers.rb +0 -27
  167. data/spec/support/helpers/api_request_helper.rb +0 -60
  168. data/spec/support/helpers/cli_helpers.rb +0 -40
  169. data/spec/support/helpers/config_helpers.rb +0 -66
  170. data/spec/support/helpers/dependency_helper.rb +0 -155
  171. data/spec/support/helpers/directory_helper.rb +0 -27
  172. data/spec/support/helpers/env_helpers.rb +0 -41
  173. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  174. data/spec/support/helpers/example_exception.rb +0 -13
  175. data/spec/support/helpers/example_standard_error.rb +0 -13
  176. data/spec/support/helpers/loader_helper.rb +0 -21
  177. data/spec/support/helpers/log_helpers.rb +0 -36
  178. data/spec/support/helpers/rails_helper.rb +0 -28
  179. data/spec/support/helpers/std_streams_helper.rb +0 -94
  180. data/spec/support/helpers/system_helpers.rb +0 -8
  181. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  182. data/spec/support/helpers/time_helpers.rb +0 -11
  183. data/spec/support/helpers/transaction_helpers.rb +0 -122
  184. data/spec/support/helpers/wait_for_helper.rb +0 -39
  185. data/spec/support/matchers/contains_log.rb +0 -26
  186. data/spec/support/matchers/have_colorized_text.rb +0 -28
  187. data/spec/support/matchers/transaction.rb +0 -200
  188. data/spec/support/mocks/appsignal_mock.rb +0 -18
  189. data/spec/support/mocks/dummy_app.rb +0 -20
  190. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  191. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  192. data/spec/support/mocks/hash_like.rb +0 -10
  193. data/spec/support/mocks/mock_probe.rb +0 -13
  194. data/spec/support/mocks/puma_mock.rb +0 -43
  195. data/spec/support/shared_examples/instrument.rb +0 -48
  196. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  197. data/spec/support/stubs/delayed_job.rb +0 -0
  198. data/spec/support/stubs/sidekiq/api.rb +0 -4
  199. data/spec/support/testing.rb +0 -203
  200. data/support/bundler_wrapper +0 -12
  201. data/support/install_deps +0 -33
@@ -1,334 +0,0 @@
1
- RSpec.describe "Puma plugin" do
2
- include WaitForHelper
3
-
4
- class MockPumaLauncher
5
- def log_writer
6
- return @log_writer if defined?(@log_writer)
7
-
8
- @log_writer = MockPumaLogWriter.new
9
- end
10
- end
11
-
12
- class MockPumaLogWriter
13
- attr_reader :logs
14
-
15
- def initialize
16
- @logs = []
17
- end
18
-
19
- def log(message)
20
- @logs << [:log, message]
21
- end
22
-
23
- def debug(message)
24
- @logs << [:debug, message]
25
- end
26
-
27
- def error(message)
28
- @logs << [:error, message]
29
- end
30
- end
31
-
32
- # StatsD server used for these tests.
33
- # Open a UDPSocket and listen for messages sent by the AppSignal Puma plugin.
34
- class StatsdServer
35
- def initialize(statsd_port)
36
- @statsd_port = statsd_port
37
- end
38
-
39
- def start
40
- stop
41
- @socket = UDPSocket.new
42
- @socket.bind("127.0.0.1", @statsd_port)
43
-
44
- loop do
45
- # Listen for messages and track them on the messages Array.
46
- packet = @socket.recvfrom(1024)
47
- track_message packet.first
48
- rescue Errno::EBADF
49
- # Ignore error for JRuby 9.1.17.0 specifically, it doesn't appear to
50
- # happen on 9.2.18.0. It doesn't break the tests themselves, ignoring
51
- # this error. It's probably a timing issue where it tries to read
52
- # from the socket after it's closed.
53
- end
54
- end
55
-
56
- def stop
57
- defined?(@socket) && @socket && @socket.close
58
- ensure
59
- @socket = nil
60
- end
61
-
62
- def messages
63
- @messages ||= []
64
- end
65
-
66
- private
67
-
68
- def track_message(message)
69
- @messages_mutex ||= Mutex.new
70
- @messages_mutex.synchronize { messages << message }
71
- end
72
- end
73
-
74
- let(:probe) { MockProbe.new }
75
- let(:launcher) { MockPumaLauncher.new }
76
- let(:hostname) { Socket.gethostname }
77
- let(:expected_default_tags) { { "hostname" => hostname } }
78
- let(:stats_data) { { :backlog => 1 } }
79
- before do
80
- module Puma
81
- def self.stats
82
- JSON.dump(@_stats_data)
83
- end
84
-
85
- def self.stats_hash
86
- @_stats_data
87
- end
88
-
89
- def self._set_stats=(data)
90
- @_stats_data = data
91
- end
92
-
93
- class Plugin
94
- class << self
95
- attr_reader :appsignal_plugin
96
-
97
- def create(&block)
98
- @appsignal_plugin = Class.new(::Puma::Plugin)
99
- @appsignal_plugin.class_eval(&block)
100
- end
101
- end
102
-
103
- attr_reader :in_background_block
104
-
105
- def in_background(&block)
106
- @in_background_block = block
107
- end
108
- end
109
- end
110
- load File.expand_path("../lib/puma/plugin/appsignal.rb", APPSIGNAL_SPEC_DIR)
111
- end
112
- after do
113
- Object.send(:remove_const, :Puma)
114
- Object.send(:remove_const, :AppsignalPumaPlugin)
115
- end
116
-
117
- def run_plugin(stats_data, plugin, &block)
118
- Puma._set_stats = stats_data
119
- ENV["APPSIGNAL_STATSD_PORT"] = "8126"
120
- @statsd = StatsdServer.new(ENV.fetch("APPSIGNAL_STATSD_PORT"))
121
- @server_thread = Thread.new { @statsd.start }
122
- @server_thread.abort_on_exception = true
123
- @client_thread = Thread.new { start_plugin(plugin) }
124
- @client_thread.abort_on_exception = true
125
- wait_for(:puma_client_wait, &block)
126
- ensure
127
- ENV["APPSIGNAL_STATSD_PORT"] = nil
128
- Puma._set_stats = nil
129
- # Stop all threads in test and stop listening on the UDPSocket
130
- @client_thread.kill if defined?(@client_thread) && @client_thread
131
- @server_thread.kill if defined?(@server_thread) && @server_thread
132
- @client_thread = nil
133
- @server_thread = nil
134
-
135
- @statsd.stop if defined?(@statsd) && @statsd
136
- @statsd = nil
137
- end
138
-
139
- def appsignal_plugin
140
- Puma::Plugin.appsignal_plugin
141
- end
142
-
143
- def start_plugin(plugin_class)
144
- plugin = plugin_class.new
145
- # Speed up test by not waiting for 60 seconds initial wait time and loop
146
- # interval.
147
- allow(plugin).to receive(:sleep_time).and_return(0.01)
148
- plugin.start(launcher)
149
- plugin.in_background_block.call
150
- end
151
-
152
- def logs
153
- launcher.log_writer.logs
154
- end
155
-
156
- def messages
157
- @statsd.messages.map do |message|
158
- metric, type, tags_string = message.split("|")
159
- metric_name, metric_value = metric.split(":")
160
- tags = {}
161
- tags_string[1..].split(",").each do |tag|
162
- key, value = tag.split(":")
163
- tags[key] = value
164
- end
165
- {
166
- :name => metric_name,
167
- :value => metric_value.to_i,
168
- :type => type,
169
- :tags => tags
170
- }
171
- end
172
- end
173
-
174
- def expect_gauge(metric_name, metric_value, tags_hash = {})
175
- expect(messages).to include(
176
- :name => "puma_#{metric_name}",
177
- :value => metric_value,
178
- :type => "g",
179
- :tags => expected_default_tags.merge(tags_hash)
180
- )
181
- end
182
-
183
- context "with multiple worker stats" do
184
- let(:stats_data) do
185
- {
186
- :workers => 2,
187
- :booted_workers => 2,
188
- :old_workers => 0,
189
- :worker_status => [
190
- {
191
- :last_status => {
192
- :backlog => 0,
193
- :running => 5,
194
- :pool_capacity => 5,
195
- :max_threads => 5
196
- }
197
- },
198
- {
199
- :last_status => {
200
- :backlog => 0,
201
- :running => 5,
202
- :pool_capacity => 5,
203
- :max_threads => 5
204
- }
205
- }
206
- ]
207
- }
208
- end
209
-
210
- it "collects puma stats as gauge metrics with the (summed) worker metrics" do
211
- run_plugin(stats_data, appsignal_plugin) do
212
- expect(logs).to_not include([:error, kind_of(String)])
213
- expect_gauge(:workers, 2, "type" => "count")
214
- expect_gauge(:workers, 2, "type" => "booted")
215
- expect_gauge(:workers, 0, "type" => "old")
216
- expect_gauge(:connection_backlog, 0)
217
- expect_gauge(:pool_capacity, 10)
218
- expect_gauge(:threads, 10, "type" => "running")
219
- expect_gauge(:threads, 10, "type" => "max")
220
- end
221
- end
222
- end
223
-
224
- context "with single worker stats" do
225
- let(:stats_data) do
226
- {
227
- :backlog => 0,
228
- :running => 5,
229
- :pool_capacity => 5,
230
- :max_threads => 5
231
- }
232
- end
233
-
234
- it "calls `puma_gauge` with the (summed) worker metrics" do
235
- run_plugin(stats_data, appsignal_plugin) do
236
- expect(logs).to_not include([:error, kind_of(String)])
237
- expect_gauge(:connection_backlog, 0)
238
- expect_gauge(:pool_capacity, 5)
239
- expect_gauge(:threads, 5, "type" => "running")
240
- expect_gauge(:threads, 5, "type" => "max")
241
- end
242
- end
243
- end
244
-
245
- context "when using APPSIGNAL_HOSTNAME" do
246
- let(:hostname) { "my-host-name" }
247
- before { ENV["APPSIGNAL_HOSTNAME"] = hostname }
248
- after { ENV.delete("APPSIGNAL_HOSTNAME") }
249
-
250
- it "reports the APPSIGNAL_HOSTNAME as the hostname tag value" do
251
- run_plugin(stats_data, appsignal_plugin) do
252
- expect(logs).to_not include([:error, kind_of(String)])
253
- expect_gauge(:connection_backlog, 1)
254
- end
255
- end
256
- end
257
-
258
- context "without Puma.stats_hash" do
259
- before do
260
- Puma.singleton_class.send(:remove_method, :stats_hash)
261
- end
262
-
263
- it "fetches metrics from Puma.stats instead" do
264
- run_plugin(stats_data, appsignal_plugin) do
265
- expect(logs).to_not include([:error, kind_of(String)])
266
- expect(logs).to_not include([kind_of(Symbol), "AppSignal: No Puma stats to report."])
267
- expect_gauge(:connection_backlog, 1)
268
- end
269
- end
270
- end
271
-
272
- context "without Puma.stats and Puma.stats_hash" do
273
- before do
274
- Puma.singleton_class.send(:remove_method, :stats)
275
- Puma.singleton_class.send(:remove_method, :stats_hash)
276
- end
277
-
278
- it "does not fetch metrics" do
279
- run_plugin(stats_data, appsignal_plugin) do
280
- expect(logs).to_not include([:error, kind_of(String)])
281
- expect(logs).to include([:debug, "AppSignal: No Puma stats to report."])
282
- expect(messages).to be_empty
283
- end
284
- end
285
- end
286
-
287
- context "without running StatsD server" do
288
- it "does nothing" do
289
- run_plugin(stats_data, appsignal_plugin) do
290
- expect(logs).to_not include([:error, kind_of(String)])
291
- expect(messages).to be_empty
292
- end
293
- end
294
- end
295
-
296
- context "with Puma < 6 Events class" do
297
- class MockPumaEvents
298
- attr_reader :logs
299
-
300
- def initialize
301
- @logs = []
302
- end
303
-
304
- def log(message)
305
- @logs << [:log, message]
306
- end
307
-
308
- def debug(message)
309
- @logs << [:debug, message]
310
- end
311
-
312
- def error(message)
313
- @logs << [:error, message]
314
- end
315
- end
316
-
317
- let(:launcher) do
318
- Class.new do
319
- def events
320
- return @events if defined?(@events)
321
-
322
- @events = MockPumaEvents.new
323
- end
324
- end.new
325
- end
326
- let(:stats_data) { { :max_threads => 5 } }
327
-
328
- it "logs messages to the events class" do
329
- run_plugin(stats_data, appsignal_plugin) do
330
- expect(launcher.events.logs).to_not be_empty
331
- end
332
- end
333
- end
334
- end
data/spec/spec_helper.rb DELETED
@@ -1,179 +0,0 @@
1
- ENV["RAILS_ENV"] ||= "test"
2
- ENV["RACK_ENV"] ||= "test"
3
- ENV["PADRINO_ENV"] ||= "test"
4
-
5
- APPSIGNAL_SPEC_DIR = File.expand_path(__dir__)
6
- $LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, "support/stubs"))
7
-
8
- Bundler.require :default
9
- require "cgi"
10
- require "rack"
11
- require "rspec"
12
- require "timecop"
13
- require "webmock/rspec"
14
-
15
- Dir[File.join(APPSIGNAL_SPEC_DIR, "support", "helpers", "*.rb")].sort.each do |f|
16
- require f
17
- end
18
- Dir[File.join(DirectoryHelper.support_dir, "mocks", "*.rb")].sort.each do |f|
19
- require f
20
- end
21
- Dir[File.join(DirectoryHelper.support_dir, "matchers", "*.rb")].sort.each do |f|
22
- require f
23
- end
24
- Dir[File.join(APPSIGNAL_SPEC_DIR, "support/shared_examples", "*.rb")].sort.each do |f|
25
- require f
26
- end
27
- if DependencyHelper.rails_present?
28
- require File.join(ConfigHelpers.rails_project_fixture_path, "config/application.rb")
29
- end
30
- if DependencyHelper.hanami2_present?
31
- Dir[File.join(DirectoryHelper.support_dir, "hanami", "*.rb")].sort.each do |f|
32
- require f
33
- end
34
- end
35
- require "pry" if DependencyHelper.dependency_present?("pry")
36
- require "appsignal"
37
- # Include patches of AppSignal modules and classes to make test helpers
38
- # available.
39
- require File.join(DirectoryHelper.support_dir, "testing.rb")
40
-
41
- puts "Running specs in #{RUBY_VERSION} on #{RUBY_PLATFORM}\n\n"
42
-
43
- # Add way to clear subscribers between specs
44
- if defined?(ActiveSupport)
45
- module ActiveSupport
46
- module Notifications
47
- class Fanout
48
- def clear_subscribers
49
- @subscribers.clear
50
- @listeners_for.clear
51
- end
52
- end
53
- end
54
- end
55
- end
56
-
57
- RSpec.configure do |config|
58
- config.include DirectoryHelper
59
- config.include StdStreamsHelper
60
- config.include ConfigHelpers
61
- config.include EnvHelpers
62
- config.include TimeHelpers
63
- config.include TransactionHelpers
64
- config.include ApiRequestHelper
65
- config.include SystemHelpers
66
- config.include LogHelpers
67
- config.include LoaderHelper
68
- config.extend DependencyHelper
69
-
70
- config.example_status_persistence_file_path = "spec/examples.txt"
71
- config.fail_if_no_examples = true
72
- config.exclude_pattern = "spec/integration/diagnose/**/*_spec.rb"
73
- config.filter_run_excluding(
74
- :extension_installation_failure => true,
75
- :jruby => !DependencyHelper.running_jruby?
76
- )
77
- config.mock_with :rspec do |mocks|
78
- mocks.syntax = :expect
79
- end
80
- config.expect_with :rspec do |expectations|
81
- expectations.syntax = :expect
82
- end
83
-
84
- def spec_system_tmp_dir
85
- File.join(tmp_dir, "system-tmp")
86
- end
87
-
88
- config.before :suite do
89
- WebMock.disable_net_connect!
90
- end
91
-
92
- config.before :context do
93
- FileUtils.rm_rf(tmp_dir)
94
- FileUtils.mkdir_p(spec_system_tmp_dir)
95
- end
96
-
97
- config.before do
98
- Appsignal.clear!
99
- Appsignal::Testing.clear!
100
- Appsignal::Loaders.clear!
101
- Appsignal::CheckIn.clear!
102
-
103
- clear_current_transaction!
104
- stop_minutely_probes
105
- ENV["RAILS_ENV"] ||= "test"
106
- ENV["RACK_ENV"] ||= "test"
107
- ENV["PADRINO_ENV"] ||= "test"
108
-
109
- # Clean environment
110
- appsignal_key_prefixes = %w[APPSIGNAL_ _APPSIGNAL_]
111
- env_keys = ENV.keys.select { |key| key.start_with?(*appsignal_key_prefixes) }
112
- # Always unset the diagnose variable
113
- # For normal Ruby this is unset in the diagnose task itself, but the JRuby
114
- # bug requires us to unset it using the method below as well. It's not
115
- # present in the ENV keys list because it's already cleared in Ruby itself
116
- # in the diagnose task, so add it manually to the list of to-be cleaned up
117
- # keys.
118
- env_keys << "_APPSIGNAL_DIAGNOSE"
119
- env_keys << "_TEST_APPSIGNAL_EXTENSION_FAILURE"
120
- env_keys.each do |key|
121
- # First set the ENV var to an empty string and then delete the key from
122
- # the env. We set the env var to an empty string first as JRuby doesn't
123
- # sync `delete` calls to extensions, making our extension think the env
124
- # var is still set after calling `ENV.delete`. Setting it to an empty
125
- # string will sort of unset it, our extension ignores env vars with an
126
- # empty string as a value.
127
- ENV[key] = ""
128
- ENV.delete(key)
129
- end
130
-
131
- # Stub system_tmp_dir to something in the project dir for specs
132
- allow(Appsignal::Config).to receive(:system_tmp_dir).and_return(spec_system_tmp_dir)
133
-
134
- # Unsubscribe Rails error reporter if present to avoid it reporting errors
135
- # multiple times through multiple subscriptions.
136
- if defined?(Rails) && Rails.respond_to?(:error)
137
- if Rails.error.respond_to?(:unsubscribe) # Future Rails version after 7.0.4.3
138
- Rails.error.unsubscribe(Appsignal::Integrations::RailsErrorReporterSubscriber)
139
- else
140
- Rails.error.instance_variable_get(:@subscribers)
141
- .delete(Appsignal::Integrations::RailsErrorReporterSubscriber)
142
- end
143
- end
144
- end
145
-
146
- # These tests are not run by default. They require a failed extension
147
- # installation. See the `rake test:failure` task. If a test with this tag was
148
- # run, run `rake extension:install` again to fix the extension installation
149
- # before running other tests.
150
- config.before :extension_installation_failure => true do
151
- next unless Appsignal.extension_loaded?
152
-
153
- raise "Extension is loaded, please run the following task and rerun the test." \
154
- "\n\n rake test:prepare_failure"
155
- end
156
-
157
- # Check to see if the extension is loaded before running the specs. If the
158
- # extension is not loaded it can result in unexpected behavior.
159
- config.before do |example|
160
- next if Appsignal.extension_loaded?
161
- next if example.metadata[:extension_installation_failure]
162
-
163
- puts "\nWARNING: The AppSignal extension is not loaded, please run the " \
164
- "following task and rerun the test." \
165
- "\n\n rake extension:install\n"
166
- end
167
-
168
- config.after do
169
- stop_minutely_probes
170
- end
171
-
172
- config.after :context do
173
- FileUtils.rm_f(File.join(project_fixture_path, "log/appsignal.log"))
174
- end
175
-
176
- def stop_minutely_probes
177
- Appsignal::Probes.stop
178
- end
179
- end
@@ -1,24 +0,0 @@
1
- default: &defaults
2
- # Your push api key, it is possible to set this dynamically using ERB:
3
- # push_api_key: "<%= ENV['APPSIGNAL_PUSH_API_KEY'] %>"
4
- push_api_key: "my_app_key"
5
-
6
- # Your app's name
7
- name: "MyApp"
8
-
9
- # The cuttoff point in ms above which a request is considered slow, default is 200
10
- # slow_request_threshold: 200
11
-
12
- # Actions that should not be monitored by AppSignal
13
- # ignore_actions:
14
- # - ApplicationController#isup
15
-
16
- # Configuration per environment, leave out an environment or set active
17
- # to false to not push metrics for that environment.
18
- development:
19
- <<: *defaults
20
- active: true
21
-
22
- production:
23
- <<: *defaults
24
- active: true
@@ -1 +0,0 @@
1
- <%= ENV.fetch("I AM A KEY THAT DOES NOT EXIST") %>
@@ -1,57 +0,0 @@
1
- default: &defaults
2
- push_api_key: "abc"
3
- name: "TestApp"
4
- enable_minutely_probes: false
5
-
6
- production:
7
- <<: *defaults
8
- active: true
9
-
10
- development:
11
- <<: *defaults
12
- active: true
13
-
14
- test:
15
- <<: *defaults
16
- endpoint: "http://localhost:3000"
17
- log_level: debug
18
- active: true
19
-
20
- old_config:
21
- api_key: "def"
22
- active: true
23
- ignore_exceptions:
24
- - StandardError
25
- request_headers: [
26
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
27
- "HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
28
- "CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
29
- "REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
30
- "SERVER_PROTOCOL", "HTTP_USER_AGENT"
31
- ]
32
-
33
- old_config_mixed_with_new_config:
34
- push_api_key: "ghi"
35
- api_key: "def"
36
- active: true
37
- ignore_errors:
38
- - NoMethodError
39
- ignore_exceptions:
40
- - StandardError
41
- request_headers: [
42
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
43
- "HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
44
- "CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
45
- "REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
46
- "SERVER_PROTOCOL", "HTTP_USER_AGENT"
47
- ]
48
-
49
- rack_env:
50
- <<: *defaults
51
-
52
- rails_env:
53
- <<: *defaults
54
-
55
- inactive_env:
56
- <<: *defaults
57
- active: false
File without changes
@@ -1,16 +0,0 @@
1
- require "rails"
2
-
3
- module MyApp
4
- class Application < Rails::Application
5
- config.active_support.deprecation = proc { |message, stack| }
6
- config.eager_load = false
7
-
8
- def self.initialize!
9
- # Prevent errors about Rails being initialized more than once
10
- return if defined?(@initialized)
11
-
12
- super
13
- @initialized = true
14
- end
15
- end
16
- end
@@ -1,56 +0,0 @@
1
- default: &defaults
2
- push_api_key: "abc"
3
- name: "TestApp"
4
- enable_minutely_probes: false
5
-
6
- production:
7
- <<: *defaults
8
- active: true
9
-
10
- development:
11
- <<: *defaults
12
- active: true
13
-
14
- test:
15
- <<: *defaults
16
- log_level: debug
17
- active: true
18
-
19
- old_config:
20
- api_key: "def"
21
- active: true
22
- ignore_exceptions:
23
- - StandardError
24
- request_headers: [
25
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
26
- "HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
27
- "CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
28
- "REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
29
- "SERVER_PROTOCOL", "HTTP_USER_AGENT"
30
- ]
31
-
32
- old_config_mixed_with_new_config:
33
- push_api_key: "ghi"
34
- api_key: "def"
35
- active: true
36
- ignore_errors:
37
- - NoMethodError
38
- ignore_exceptions:
39
- - StandardError
40
- request_headers: [
41
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
42
- "HTTP_ACCEPT_LANGUAGE", "HTTP_CACHE_CONTROL", "HTTP_CONNECTION",
43
- "CONTENT_LENGTH", "PATH_INFO", "HTTP_RANGE", "HTTP_REFERER",
44
- "REQUEST_METHOD", "REQUEST_PATH", "SERVER_NAME", "SERVER_PORT",
45
- "SERVER_PROTOCOL", "HTTP_USER_AGENT"
46
- ]
47
-
48
- rack_env:
49
- <<: *defaults
50
-
51
- rails_env:
52
- <<: *defaults
53
-
54
- inactive_env:
55
- <<: *defaults
56
- active: false
@@ -1,10 +0,0 @@
1
- # Load the Rails application.
2
- require_relative "application"
3
-
4
- # Initialize the Rails application.
5
- MyApp::Application.initialize!
6
-
7
- # Asserted from the diagnose spec
8
- Appsignal.configure do |config|
9
- config.ignore_actions = ["Action from DSL"]
10
- end
File without changes