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,443 +0,0 @@
1
- describe Appsignal::CheckIn::Scheduler do
2
- include WaitForHelper
3
- include TakeAtMostHelper
4
-
5
- let(:log_stream) { std_stream }
6
- let(:logs) { log_contents(log_stream) }
7
- let(:appsignal_options) { {} }
8
- let(:transmitter) { Appsignal::Transmitter.new("http://checkin-endpoint.invalid") }
9
-
10
- before do
11
- start_agent(:options => appsignal_options, :internal_logger => test_logger(log_stream))
12
- allow(transmitter).to receive(:transmit).and_return(Net::HTTPSuccess.new("1.1", 200, "OK"))
13
- allow(Appsignal::CheckIn).to receive(:transmitter).and_return(transmitter)
14
- allow(Appsignal::CheckIn).to receive(:scheduler).and_return(subject)
15
- # Shorten debounce intervals to make the tests run faster.
16
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 0.1)
17
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 0.1)
18
- end
19
-
20
- after do
21
- subject.stop
22
- end
23
-
24
- describe "when no event is sent" do
25
- it "does not start a thread" do
26
- expect(subject.thread).to be_nil
27
- end
28
-
29
- it "does not schedule a debounce" do
30
- expect(subject.waker).to be_nil
31
- end
32
-
33
- it "can be stopped" do
34
- # Set all debounce intervals to 10 seconds, to make the assertion
35
- # fail if it waits for the debounce -- this ensures that what is being
36
- # tested is that no debounces are awaited when stopping the scheduler.
37
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
38
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
39
-
40
- take_at_most(0.1) do
41
- expect { subject.stop }.not_to raise_error
42
- end
43
- end
44
-
45
- it "can be stopped more than once" do
46
- # Set all debounce intervals to 10 seconds, to make the assertion
47
- # fail if it waits for the debounce -- this ensures that what is being
48
- # tested is that no debounces are awaited when stopping the scheduler.
49
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
50
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
51
-
52
- take_at_most(0.1) do
53
- expect { subject.stop }.not_to raise_error
54
- expect { subject.stop }.not_to raise_error
55
- end
56
- end
57
-
58
- it "closes the queue when stopped" do
59
- subject.stop
60
- expect(subject.queue.closed?).to be(true)
61
- end
62
- end
63
-
64
- describe "when an event is sent" do
65
- it "starts a thread" do
66
- Appsignal::CheckIn.cron("test")
67
- expect(subject.thread).to be_a(Thread)
68
- end
69
-
70
- it "schedules a debounce" do
71
- Appsignal::CheckIn.cron("test")
72
- expect(subject.waker).to be_a(Thread)
73
- end
74
-
75
- it "schedules the event to be transmitted" do
76
- expect(transmitter).to receive(:transmit).with([hash_including(
77
- :identifier => "test",
78
- :check_in_type => "cron",
79
- :kind => "finish"
80
- )], :format => :ndjson)
81
-
82
- expect(subject.events).to be_empty
83
-
84
- Appsignal::CheckIn.cron("test")
85
-
86
- expect(subject.events).not_to be_empty
87
-
88
- wait_for("the event to be transmitted") { subject.transmitted == 1 }
89
-
90
- expect(subject.events).to be_empty
91
-
92
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
93
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
94
- end
95
-
96
- it "waits for the event to be transmitted when stopped" do
97
- # Set all debounce intervals to 10 seconds, to make the test
98
- # fail if it waits for the debounce -- this ensures that what is being
99
- # tested is that the events are transmitted immediately when the
100
- # scheduler is stopped, without waiting for any debounce.
101
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
102
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
103
-
104
- expect(transmitter).to receive(:transmit).with([hash_including(
105
- :identifier => "test",
106
- :check_in_type => "cron",
107
- :kind => "finish"
108
- )], :format => :ndjson)
109
-
110
- Appsignal::CheckIn.cron("test")
111
-
112
- expect(subject.events).not_to be_empty
113
-
114
- take_at_most(0.1) do
115
- expect { subject.stop }.not_to raise_error
116
- end
117
-
118
- # Check that the thread wasn't killed before the transmission was
119
- # completed.
120
- expect(subject.transmitted).to eq(1)
121
-
122
- expect(subject.events).to be_empty
123
-
124
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
125
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
126
- end
127
-
128
- it "can be stopped more than once" do
129
- # Set all debounce intervals to 10 seconds, to make the test
130
- # fail if it waits for the debounce -- this ensures that what is being
131
- # tested is that the events are transmitted immediately when the
132
- # scheduler is stopped, without waiting for the debounce interval.
133
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
134
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
135
-
136
- Appsignal::CheckIn.cron("test")
137
- take_at_most(0.1) do
138
- expect { subject.stop }.not_to raise_error
139
- end
140
-
141
- # Check that the thread wasn't killed before the transmission was
142
- # completed.
143
- expect(subject.transmitted).to eq(1)
144
-
145
- take_at_most(0.1) do
146
- expect { subject.stop }.not_to raise_error
147
- end
148
- end
149
-
150
- it "closes the queue when stopped" do
151
- Appsignal::CheckIn.cron("test")
152
- subject.stop
153
- expect(subject.queue.closed?).to be(true)
154
- end
155
-
156
- it "kills the thread when stopped" do
157
- Appsignal::CheckIn.cron("test")
158
- subject.stop
159
- expect(subject.thread.alive?).to be(false)
160
- end
161
-
162
- it "unschedules the debounce when stopped" do
163
- Appsignal::CheckIn.cron("test")
164
- waker = subject.waker
165
- subject.stop
166
- expect(waker.alive?).to be(false)
167
- expect(subject.waker).to be_nil
168
- end
169
- end
170
-
171
- describe "when many events are sent" do
172
- describe "within the short debounce interval" do
173
- it "transmits all events at once" do
174
- expect(transmitter).to receive(:transmit).with(
175
- ["first", "second", "third"].map do |identifier|
176
- hash_including(
177
- :identifier => identifier,
178
- :check_in_type => "cron",
179
- :kind => "finish"
180
- )
181
- end, :format => :ndjson
182
- )
183
-
184
- Appsignal::CheckIn.cron("first")
185
- Appsignal::CheckIn.cron("second")
186
- Appsignal::CheckIn.cron("third")
187
-
188
- wait_for("the events to be transmitted") { subject.transmitted == 1 }
189
- end
190
-
191
- it "transmits all events at once when stopped" do
192
- # Set a short debounce interval of 10 seconds, to make the final wait
193
- # fail if it waits for the debounce -- this ensures that what is being
194
- # tested is that the events are transmitted when the scheduler is
195
- # stopped.
196
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
197
-
198
- expect(transmitter).to receive(:transmit).with(
199
- ["first", "second", "third"].map do |identifier|
200
- hash_including(
201
- :identifier => identifier,
202
- :check_in_type => "cron",
203
- :kind => "finish"
204
- )
205
- end, :format => :ndjson
206
- )
207
-
208
- Appsignal::CheckIn.cron("first")
209
- Appsignal::CheckIn.cron("second")
210
- Appsignal::CheckIn.cron("third")
211
-
212
- subject.stop
213
-
214
- wait_for("the events to be transmitted") { subject.transmitted == 1 }
215
- end
216
- end
217
-
218
- describe "further apart than the short debounce interval" do
219
- it "transmits the first event and enqueues future events" do
220
- expect(transmitter).to receive(:transmit).with([hash_including(
221
- :identifier => "first",
222
- :check_in_type => "cron",
223
- :kind => "finish"
224
- )], :format => :ndjson)
225
-
226
- Appsignal::CheckIn.cron("first")
227
-
228
- wait_for("the first event to be transmitted") { subject.transmitted == 1 }
229
-
230
- Appsignal::CheckIn.cron("second")
231
- Appsignal::CheckIn.cron("third")
232
-
233
- expect(subject.events).to match(["second", "third"].map do |identifier|
234
- hash_including({
235
- :identifier => identifier,
236
- :check_in_type => "cron",
237
- :kind => "finish"
238
- })
239
- end)
240
- end
241
-
242
- it "transmits the other events after the debounce interval" do
243
- expect(transmitter).to receive(:transmit)
244
-
245
- Appsignal::CheckIn.cron("first")
246
-
247
- wait_for("the first event to be transmitted") { subject.transmitted == 1 }
248
-
249
- expect(transmitter).to receive(:transmit).with(
250
- ["second", "third"].map do |identifier|
251
- hash_including(
252
- :identifier => identifier,
253
- :check_in_type => "cron",
254
- :kind => "finish"
255
- )
256
- end, :format => :ndjson
257
- )
258
-
259
- Appsignal::CheckIn.cron("second")
260
- Appsignal::CheckIn.cron("third")
261
-
262
- expect(subject.events).to_not be_empty
263
-
264
- wait_for("the other events to be transmitted") { subject.transmitted == 2 }
265
-
266
- expect(subject.events).to be_empty
267
-
268
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
269
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
270
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
271
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
272
- expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
273
- end
274
-
275
- it "transmits the other events when stopped" do
276
- # Restore the original long debounce interval of 10 seconds, to make
277
- # the final wait fail if it waits for the debounce -- this ensures
278
- # that what is being tested is that the events are transmitted
279
- # immediately when the scheduler is stopped.
280
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
281
-
282
- expect(transmitter).to receive(:transmit)
283
-
284
- Appsignal::CheckIn.cron("first")
285
-
286
- wait_for("the event to be transmitted") { subject.transmitted == 1 }
287
-
288
- expect(transmitter).to receive(:transmit).with(
289
- ["second", "third"].map do |identifier|
290
- hash_including(
291
- :identifier => identifier,
292
- :check_in_type => "cron",
293
- :kind => "finish"
294
- )
295
- end, :format => :ndjson
296
- )
297
-
298
- Appsignal::CheckIn.cron("second")
299
- Appsignal::CheckIn.cron("third")
300
-
301
- expect(subject.events).to_not be_empty
302
-
303
- subject.stop
304
-
305
- wait_for("the other events to be transmitted") { subject.transmitted == 2 }
306
-
307
- expect(subject.events).to be_empty
308
-
309
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
310
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
311
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
312
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
313
- expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
314
- end
315
- end
316
- end
317
-
318
- describe "when a similar event is sent more than once" do
319
- it "only transmits one of the similar events" do
320
- # We must instantiate `Appsignal::CheckIn::Cron` directly, as the
321
- # `.cron` helper would use a different digest for each invocation.
322
- cron = Appsignal::CheckIn::Cron.new(:identifier => "test")
323
-
324
- expect(transmitter).to receive(:transmit).with([hash_including(
325
- :identifier => "test",
326
- :check_in_type => "cron",
327
- :kind => "start"
328
- )], :format => :ndjson)
329
-
330
- cron.start
331
- cron.start
332
-
333
- wait_for("the event to be transmitted") { subject.transmitted == 1 }
334
-
335
- expect(logs).to contains_log(
336
- :debug,
337
- "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
338
- )
339
- expect(logs).to contains_log(
340
- :debug,
341
- "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
342
- )
343
- expect(logs).to contains_log(
344
- :debug,
345
- "Replacing previously scheduled cron check-in `test` start event (digest #{cron.digest})"
346
- )
347
- expect(logs).to contains_log(
348
- :debug,
349
- "Transmitted cron check-in `test` start event (digest #{cron.digest})"
350
- )
351
- end
352
- end
353
-
354
- describe "when the scheduler is stopped" do
355
- it "does not schedule any events to be transmitted" do
356
- expect(transmitter).not_to receive(:transmit)
357
-
358
- subject.stop
359
-
360
- Appsignal::CheckIn.cron("test")
361
-
362
- expect(subject.events).to be_empty
363
-
364
- expect(logs).to contains_log(
365
- :debug,
366
- /Cannot transmit cron check-in `test` finish event .+: AppSignal is stopped/
367
- )
368
- end
369
- end
370
-
371
- describe "when AppSignal is not active" do
372
- let(:appsignal_options) { { :active => false } }
373
-
374
- it "does not schedule any events to be transmitted" do
375
- subject.stop
376
-
377
- Appsignal::CheckIn.cron("test")
378
-
379
- expect(subject.events).to be_empty
380
-
381
- expect(logs).to contains_log(
382
- :debug,
383
- /Cannot transmit cron check-in `test` finish event .+: AppSignal is not active/
384
- )
385
- end
386
- end
387
-
388
- describe "when transmitting returns a non-success response code" do
389
- it "logs the error and continues" do
390
- expect(transmitter).to receive(:transmit).and_return(
391
- Net::HTTPNotFound.new("1.1", 404, "Not Found")
392
- )
393
-
394
- Appsignal::CheckIn.cron("first")
395
-
396
- wait_for("the first event to be transmitted") { subject.transmitted == 1 }
397
-
398
- expect(transmitter).to receive(:transmit).and_return(
399
- Net::HTTPSuccess.new("1.1", 200, "OK")
400
- )
401
-
402
- Appsignal::CheckIn.cron("second")
403
-
404
- wait_for("the second event to be transmitted") { subject.transmitted == 2 }
405
-
406
- expect(logs).to contains_log(
407
- :error,
408
- /Failed to transmit cron check-in `first` finish event .+: 404 status code/
409
- )
410
- expect(logs).to contains_log(
411
- :debug,
412
- "Transmitted cron check-in `second` finish event"
413
- )
414
- end
415
- end
416
-
417
- describe "when transmitting throws an error" do
418
- it "logs the error and continues" do
419
- expect(transmitter).to receive(:transmit).and_raise("Something went wrong")
420
-
421
- Appsignal::CheckIn.cron("first")
422
-
423
- wait_for("the first event to be transmitted") { subject.transmitted == 1 }
424
-
425
- expect(transmitter).to receive(:transmit).and_return(
426
- Net::HTTPSuccess.new("1.1", 200, "OK")
427
- )
428
-
429
- Appsignal::CheckIn.cron("second")
430
-
431
- wait_for("the second event to be transmitted") { subject.transmitted == 2 }
432
-
433
- expect(logs).to contains_log(
434
- :error,
435
- /Failed to transmit cron check-in `first` finish event .+: Something went wrong/
436
- )
437
- expect(logs).to contains_log(
438
- :debug,
439
- "Transmitted cron check-in `second` finish event"
440
- )
441
- end
442
- end
443
- end
@@ -1,46 +0,0 @@
1
- require "appsignal/cli"
2
-
3
- describe Appsignal::CLI::Demo do
4
- include CLIHelpers
5
-
6
- let(:options) { {} }
7
- let(:out_stream) { std_stream }
8
- let(:output) { out_stream.read }
9
- before(:context) { Appsignal.stop }
10
-
11
- def run
12
- run_within_dir project_fixture_path
13
- end
14
-
15
- def run_within_dir(chdir)
16
- Dir.chdir chdir do
17
- capture_stdout(out_stream) { run_cli("demo", options) }
18
- end
19
- end
20
-
21
- context "without configuration" do
22
- it "returns an error" do
23
- expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
24
-
25
- expect(output).to include("Error: Unable to start the AppSignal agent")
26
- end
27
- end
28
-
29
- context "with configuration" do
30
- before do
31
- # Ignore sleeps to speed up the test
32
- allow(Appsignal::Demo).to receive(:sleep)
33
- end
34
- let(:options) { { :environment => "development" } }
35
-
36
- it "calls Appsignal::Demo transmitter" do
37
- expect(Appsignal::Demo).to receive(:transmit).and_return(true)
38
- run
39
- end
40
-
41
- it "outputs message" do
42
- run
43
- expect(output).to include("Demonstration sample data sent!")
44
- end
45
- end
46
- end
@@ -1,16 +0,0 @@
1
- require "bundler/cli"
2
- require "bundler/cli/common"
3
- require "appsignal/cli/diagnose/paths"
4
-
5
- describe Appsignal::CLI::Diagnose::Paths do
6
- describe "#paths" do
7
- before { start_agent }
8
-
9
- it "returns gem installation path as package_install_path" do
10
- expect(described_class.new.paths[:package_install_path]).to eq(
11
- :label => "AppSignal gem path",
12
- :path => Bundler::CLI::Common.select_spec("appsignal").full_gem_path.strip
13
- )
14
- end
15
- end
16
- end
@@ -1,86 +0,0 @@
1
- require "appsignal/cli/diagnose/utils"
2
-
3
- describe Appsignal::CLI::Diagnose::Utils do
4
- describe ".username_for_uid" do
5
- subject { described_class.username_for_uid(uid) }
6
-
7
- context "when user with id exists" do
8
- let(:uid) { 0 }
9
-
10
- it "returns username" do
11
- is_expected.to be_kind_of(String)
12
- end
13
- end
14
-
15
- context "when user with id does not exist" do
16
- let(:uid) { -1 }
17
-
18
- it "returns nil" do
19
- is_expected.to be_nil
20
- end
21
- end
22
- end
23
-
24
- describe ".group_for_gid" do
25
- subject { described_class.group_for_gid(uid) }
26
-
27
- context "when group with id exists" do
28
- let(:uid) { 0 }
29
-
30
- it "returns group name" do
31
- is_expected.to be_kind_of(String)
32
- end
33
- end
34
-
35
- context "when group with id does not exist" do
36
- let(:uid) { -3 }
37
-
38
- it "returns nil" do
39
- is_expected.to be_nil
40
- end
41
- end
42
- end
43
-
44
- describe ".read_file_content" do
45
- let(:path) { File.join(spec_system_tmp_dir, "test_file.txt") }
46
- let(:bytes_to_read) { 100 }
47
- subject { described_class.read_file_content(path, bytes_to_read) }
48
- before do
49
- File.write(path, file_contents)
50
- end
51
-
52
- context "when file is bigger than read size" do
53
- let(:file_contents) do
54
- "".tap do |s|
55
- 100.times do |i|
56
- s << "line #{i}\n"
57
- end
58
- end
59
- end
60
-
61
- it "returns the last X bytes" do
62
- is_expected
63
- .to eq(file_contents[(file_contents.length - bytes_to_read)..file_contents.length])
64
- end
65
- end
66
-
67
- context "when file is smaller than read size" do
68
- let(:file_contents) { "line 1\n" }
69
-
70
- it "returns the whole file content" do
71
- is_expected.to eq(file_contents)
72
- end
73
- end
74
-
75
- context "when reading the file raises an illegal seek error" do
76
- let(:file_contents) { "line 1\n" }
77
- before do
78
- expect(File).to receive(:binread).and_raise(Errno::ESPIPE)
79
- end
80
-
81
- it "returns the error as the content" do
82
- expect { subject }.to raise_error(Errno::ESPIPE)
83
- end
84
- end
85
- end
86
- end