appsignal 4.0.5 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/build_matrix.yml +2 -1
  6. data/ext/agent.rb +27 -27
  7. data/lib/appsignal/check_in/scheduler.rb +3 -4
  8. data/lib/appsignal/check_in.rb +1 -1
  9. data/lib/appsignal/config.rb +1 -3
  10. data/lib/appsignal/integrations/que.rb +8 -2
  11. data/lib/appsignal/integrations/resque.rb +1 -6
  12. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  13. data/lib/appsignal/version.rb +1 -1
  14. metadata +2 -191
  15. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  16. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  17. data/.github/workflows/ci.yml +0 -3150
  18. data/.github/workflows/create_release_from_tag.yml +0 -62
  19. data/.gitignore +0 -35
  20. data/.gitmodules +0 -3
  21. data/.rspec +0 -4
  22. data/.yardopts +0 -8
  23. data/benchmark.rake +0 -139
  24. data/gemfiles/capistrano2.gemfile +0 -6
  25. data/gemfiles/capistrano3.gemfile +0 -7
  26. data/gemfiles/dry-monitor.gemfile +0 -5
  27. data/gemfiles/grape.gemfile +0 -5
  28. data/gemfiles/hanami-2.0.gemfile +0 -7
  29. data/gemfiles/hanami-2.1.gemfile +0 -7
  30. data/gemfiles/http5.gemfile +0 -5
  31. data/gemfiles/no_dependencies.gemfile +0 -10
  32. data/gemfiles/padrino.gemfile +0 -7
  33. data/gemfiles/psych-3.gemfile +0 -5
  34. data/gemfiles/psych-4.gemfile +0 -5
  35. data/gemfiles/que.gemfile +0 -5
  36. data/gemfiles/rails-6.0.gemfile +0 -10
  37. data/gemfiles/rails-6.1.gemfile +0 -11
  38. data/gemfiles/rails-7.0.gemfile +0 -11
  39. data/gemfiles/rails-7.1.gemfile +0 -11
  40. data/gemfiles/rails-7.2.gemfile +0 -11
  41. data/gemfiles/redis-4.gemfile +0 -5
  42. data/gemfiles/redis-5.gemfile +0 -6
  43. data/gemfiles/resque-2.gemfile +0 -6
  44. data/gemfiles/sequel.gemfile +0 -10
  45. data/gemfiles/sinatra.gemfile +0 -5
  46. data/gemfiles/webmachine1.gemfile +0 -7
  47. data/gemfiles/webmachine2.gemfile +0 -6
  48. data/mono.yml +0 -16
  49. data/spec/.rubocop.yml +0 -7
  50. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  51. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  52. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  53. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
  54. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
  55. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  56. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  57. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  58. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  59. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  60. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  61. data/spec/lib/appsignal/cli_spec.rb +0 -56
  62. data/spec/lib/appsignal/config_spec.rb +0 -1380
  63. data/spec/lib/appsignal/demo_spec.rb +0 -83
  64. data/spec/lib/appsignal/environment_spec.rb +0 -190
  65. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  66. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  67. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  69. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  70. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  71. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  72. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  73. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  74. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  75. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  76. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  77. data/spec/lib/appsignal/extension_spec.rb +0 -178
  78. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  79. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  80. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  81. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  82. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  83. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  84. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  85. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  86. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  87. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  88. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  89. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  90. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  91. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  92. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  93. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  94. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  95. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  96. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  97. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  98. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  99. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  100. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  101. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  102. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  103. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  104. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  105. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  106. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  107. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  108. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  109. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  110. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  111. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  112. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  113. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  114. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  115. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  116. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  117. data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
  118. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  119. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  120. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  121. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  122. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  123. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  124. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  125. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  126. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  127. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  128. data/spec/lib/appsignal/logger_spec.rb +0 -205
  129. data/spec/lib/appsignal/marker_spec.rb +0 -51
  130. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  131. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  132. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  133. data/spec/lib/appsignal/probes_spec.rb +0 -411
  134. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  135. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  136. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  137. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  138. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  139. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  140. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  141. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  142. data/spec/lib/appsignal/rack_spec.rb +0 -243
  143. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  144. data/spec/lib/appsignal/span_spec.rb +0 -141
  145. data/spec/lib/appsignal/system_spec.rb +0 -126
  146. data/spec/lib/appsignal/transaction_spec.rb +0 -2111
  147. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  148. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  149. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  150. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  151. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  152. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  153. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  154. data/spec/lib/appsignal_spec.rb +0 -1919
  155. data/spec/lib/puma/appsignal_spec.rb +0 -334
  156. data/spec/spec_helper.rb +0 -173
  157. data/spec/support/fixtures/generated_config.yml +0 -24
  158. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  159. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  160. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  162. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  163. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  164. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  165. data/spec/support/fixtures/uploaded_file.txt +0 -0
  166. data/spec/support/hanami/hanami_app.rb +0 -29
  167. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  168. data/spec/support/helpers/activejob_helpers.rb +0 -27
  169. data/spec/support/helpers/api_request_helper.rb +0 -20
  170. data/spec/support/helpers/cli_helpers.rb +0 -40
  171. data/spec/support/helpers/config_helpers.rb +0 -66
  172. data/spec/support/helpers/dependency_helper.rb +0 -150
  173. data/spec/support/helpers/directory_helper.rb +0 -27
  174. data/spec/support/helpers/env_helpers.rb +0 -41
  175. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  176. data/spec/support/helpers/example_exception.rb +0 -13
  177. data/spec/support/helpers/example_standard_error.rb +0 -13
  178. data/spec/support/helpers/loader_helper.rb +0 -21
  179. data/spec/support/helpers/log_helpers.rb +0 -36
  180. data/spec/support/helpers/rails_helper.rb +0 -28
  181. data/spec/support/helpers/std_streams_helper.rb +0 -94
  182. data/spec/support/helpers/system_helpers.rb +0 -8
  183. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  184. data/spec/support/helpers/time_helpers.rb +0 -11
  185. data/spec/support/helpers/transaction_helpers.rb +0 -122
  186. data/spec/support/helpers/wait_for_helper.rb +0 -39
  187. data/spec/support/matchers/contains_log.rb +0 -26
  188. data/spec/support/matchers/have_colorized_text.rb +0 -28
  189. data/spec/support/matchers/transaction.rb +0 -200
  190. data/spec/support/mocks/appsignal_mock.rb +0 -18
  191. data/spec/support/mocks/dummy_app.rb +0 -20
  192. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  193. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  194. data/spec/support/mocks/hash_like.rb +0 -10
  195. data/spec/support/mocks/mock_probe.rb +0 -13
  196. data/spec/support/mocks/puma_mock.rb +0 -43
  197. data/spec/support/shared_examples/instrument.rb +0 -48
  198. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  199. data/spec/support/stubs/delayed_job.rb +0 -0
  200. data/spec/support/stubs/sidekiq/api.rb +0 -4
  201. data/spec/support/testing.rb +0 -194
  202. data/support/bundler_wrapper +0 -12
  203. 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,173 +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 :context do
89
- FileUtils.rm_rf(tmp_dir)
90
- FileUtils.mkdir_p(spec_system_tmp_dir)
91
- end
92
-
93
- config.before do
94
- Appsignal.clear!
95
- Appsignal::Testing.clear!
96
- Appsignal::Loaders.clear!
97
- clear_current_transaction!
98
- stop_minutely_probes
99
- ENV["RAILS_ENV"] ||= "test"
100
- ENV["RACK_ENV"] ||= "test"
101
- ENV["PADRINO_ENV"] ||= "test"
102
-
103
- # Clean environment
104
- appsignal_key_prefixes = %w[APPSIGNAL_ _APPSIGNAL_]
105
- env_keys = ENV.keys.select { |key| key.start_with?(*appsignal_key_prefixes) }
106
- # Always unset the diagnose variable
107
- # For normal Ruby this is unset in the diagnose task itself, but the JRuby
108
- # bug requires us to unset it using the method below as well. It's not
109
- # present in the ENV keys list because it's already cleared in Ruby itself
110
- # in the diagnose task, so add it manually to the list of to-be cleaned up
111
- # keys.
112
- env_keys << "_APPSIGNAL_DIAGNOSE"
113
- env_keys << "_TEST_APPSIGNAL_EXTENSION_FAILURE"
114
- env_keys.each do |key|
115
- # First set the ENV var to an empty string and then delete the key from
116
- # the env. We set the env var to an empty string first as JRuby doesn't
117
- # sync `delete` calls to extensions, making our extension think the env
118
- # var is still set after calling `ENV.delete`. Setting it to an empty
119
- # string will sort of unset it, our extension ignores env vars with an
120
- # empty string as a value.
121
- ENV[key] = ""
122
- ENV.delete(key)
123
- end
124
-
125
- # Stub system_tmp_dir to something in the project dir for specs
126
- allow(Appsignal::Config).to receive(:system_tmp_dir).and_return(spec_system_tmp_dir)
127
-
128
- # Unsubscribe Rails error reporter if present to avoid it reporting errors
129
- # multiple times through multiple subscriptions.
130
- if defined?(Rails) && Rails.respond_to?(:error)
131
- if Rails.error.respond_to?(:unsubscribe) # Future Rails version after 7.0.4.3
132
- Rails.error.unsubscribe(Appsignal::Integrations::RailsErrorReporterSubscriber)
133
- else
134
- Rails.error.instance_variable_get(:@subscribers)
135
- .delete(Appsignal::Integrations::RailsErrorReporterSubscriber)
136
- end
137
- end
138
- end
139
-
140
- # These tests are not run by default. They require a failed extension
141
- # installation. See the `rake test:failure` task. If a test with this tag was
142
- # run, run `rake extension:install` again to fix the extension installation
143
- # before running other tests.
144
- config.before :extension_installation_failure => true do
145
- next unless Appsignal.extension_loaded?
146
-
147
- raise "Extension is loaded, please run the following task and rerun the test." \
148
- "\n\n rake test:prepare_failure"
149
- end
150
-
151
- # Check to see if the extension is loaded before running the specs. If the
152
- # extension is not loaded it can result in unexpected behavior.
153
- config.before do |example|
154
- next if Appsignal.extension_loaded?
155
- next if example.metadata[:extension_installation_failure]
156
-
157
- puts "\nWARNING: The AppSignal extension is not loaded, please run the " \
158
- "following task and rerun the test." \
159
- "\n\n rake extension:install\n"
160
- end
161
-
162
- config.after do
163
- stop_minutely_probes
164
- end
165
-
166
- config.after :context do
167
- FileUtils.rm_f(File.join(project_fixture_path, "log/appsignal.log"))
168
- end
169
-
170
- def stop_minutely_probes
171
- Appsignal::Probes.stop
172
- end
173
- 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