appsignal 4.0.6-java → 4.0.7-java

Sign up to get free protection for your applications and to get access to all the features.
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,454 +0,0 @@
1
- describe "Appsignal::Integrations::DelayedJobHook" do
2
- before(:context) do
3
- module Delayed
4
- class Plugin
5
- def self.callbacks
6
- end
7
- end
8
-
9
- class Worker
10
- def self.plugins
11
- @plugins ||= []
12
- end
13
- end
14
- end
15
- require "appsignal/integrations/delayed_job_plugin"
16
- end
17
- after(:context) { Object.send(:remove_const, :Delayed) }
18
- let(:options) { {} }
19
- before { start_agent(:options => options) }
20
-
21
- # We haven't found a way to test the hooks, we'll have to do that manually
22
-
23
- describe ".invoke_with_instrumentation" do
24
- let(:plugin) { Appsignal::Integrations::DelayedJobPlugin }
25
- let(:time) { Time.parse("01-01-2001 10:01:00UTC") }
26
- let(:created_at) { time - 3600 }
27
- let(:run_at) { time - 3600 }
28
- let(:payload_object) { double(:args => args) }
29
- let(:job_data) do
30
- {
31
- :id => 123,
32
- :name => "TestClass#perform",
33
- :priority => 1,
34
- :attempts => 1,
35
- :queue => "default",
36
- :created_at => created_at,
37
- :run_at => run_at,
38
- :payload_object => payload_object
39
- }
40
- end
41
- let(:args) { ["argument"] }
42
- let(:job) { double(job_data) }
43
- let(:invoked_block) { proc {} }
44
-
45
- def perform
46
- Timecop.freeze(time) do
47
- keep_transactions do
48
- plugin.invoke_with_instrumentation(job, invoked_block)
49
- end
50
- end
51
- end
52
-
53
- context "with a normal call" do
54
- it "wraps it in a transaction" do
55
- perform
56
-
57
- transaction = last_transaction
58
- expect(transaction).to have_namespace("background_job")
59
- expect(transaction).to have_action("TestClass#perform")
60
- expect(transaction).to_not have_error
61
- expect(transaction).to include_event(:name => "perform_job.delayed_job")
62
- expect(transaction).to include_tags(
63
- "priority" => 1,
64
- "attempts" => 1,
65
- "queue" => "default",
66
- "id" => "123"
67
- )
68
- expect(transaction).to include_params(["argument"])
69
- end
70
-
71
- context "with more complex params" do
72
- let(:args) do
73
- {
74
- :foo => "Foo",
75
- :bar => "Bar"
76
- }
77
- end
78
-
79
- it "adds the more complex arguments" do
80
- perform
81
-
82
- expect(last_transaction).to include_params("foo" => "Foo", "bar" => "Bar")
83
- end
84
-
85
- context "with parameter filtering" do
86
- let(:options) { { :filter_parameters => ["foo"] } }
87
-
88
- it "filters selected arguments" do
89
- perform
90
-
91
- expect(last_transaction).to include_params("foo" => "[FILTERED]", "bar" => "Bar")
92
- end
93
- end
94
- end
95
-
96
- context "with run_at in the future" do
97
- let(:run_at) { Time.parse("2017-01-01 10:01:00UTC") }
98
-
99
- it "reports queue_start with run_at time" do
100
- perform
101
-
102
- expect(last_transaction).to have_queue_start(run_at.to_i * 1000)
103
- end
104
- end
105
-
106
- context "with class method job" do
107
- let(:job_data) do
108
- { :name => "CustomClassMethod.perform", :payload_object => payload_object }
109
- end
110
-
111
- it "wraps it in a transaction using the class method job name" do
112
- perform
113
- expect(last_transaction).to have_action("CustomClassMethod.perform")
114
- end
115
- end
116
-
117
- context "with custom name call" do
118
- before { perform }
119
-
120
- context "with appsignal_name defined" do
121
- context "with payload_object being an object" do
122
- context "with value" do
123
- let(:payload_object) { double(:appsignal_name => "CustomClass#perform") }
124
-
125
- it "wraps it in a transaction using the custom name" do
126
- expect(last_transaction).to have_action("CustomClass#perform")
127
- end
128
- end
129
-
130
- context "with non-String value" do
131
- let(:payload_object) { double(:appsignal_name => Object.new) }
132
-
133
- it "wraps it in a transaction using the original job name" do
134
- expect(last_transaction).to have_action("TestClass#perform")
135
- end
136
- end
137
-
138
- context "with class method name as job" do
139
- let(:payload_object) { double(:appsignal_name => "CustomClassMethod.perform") }
140
-
141
- it "wraps it in a transaction using the custom name" do
142
- perform
143
- expect(last_transaction).to have_action("CustomClassMethod.perform")
144
- end
145
- end
146
- end
147
-
148
- context "with payload_object being a Hash" do
149
- context "with value" do
150
- let(:payload_object) { double(:appsignal_name => "CustomClassHash#perform") }
151
-
152
- it "wraps it in a transaction using the custom name" do
153
- expect(last_transaction).to have_action("CustomClassHash#perform")
154
- end
155
- end
156
-
157
- context "with non-String value" do
158
- let(:payload_object) { double(:appsignal_name => Object.new) }
159
-
160
- it "wraps it in a transaction using the original job name" do
161
- expect(last_transaction).to have_action("TestClass#perform")
162
- end
163
- end
164
-
165
- context "with class method name as job" do
166
- let(:payload_object) { { :appsignal_name => "CustomClassMethod.perform" } }
167
-
168
- it "wraps it in a transaction using the custom name" do
169
- perform
170
- expect(last_transaction).to have_action("CustomClassMethod.perform")
171
- end
172
- end
173
- end
174
-
175
- context "with payload_object acting like a Hash and returning a non-String value" do
176
- class ClassActingAsHash
177
- def self.[](_key)
178
- Object.new
179
- end
180
-
181
- def self.appsignal_name
182
- "ClassActingAsHash#perform"
183
- end
184
- end
185
- let(:payload_object) { ClassActingAsHash }
186
-
187
- # We check for hash values before object values
188
- # this means ClassActingAsHash returns `Object.new` instead
189
- # of `self.appsignal_name`. Since this isn't a valid `String`
190
- # we return the default job name as action name.
191
- it "wraps it in a transaction using the original job name" do
192
- expect(last_transaction).to have_action("TestClass#perform")
193
- end
194
- end
195
- end
196
- end
197
-
198
- context "with only job class name" do
199
- let(:job_data) do
200
- { :name => "Banana", :payload_object => payload_object }
201
- end
202
-
203
- it "appends #perform to the class name" do
204
- perform
205
- expect(last_transaction).to have_action("Banana#perform")
206
- end
207
- end
208
-
209
- if active_job_present?
210
- require "active_job"
211
-
212
- context "when wrapped by ActiveJob" do
213
- let(:payload_object) do
214
- ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.new(
215
- "arguments" => args,
216
- "job_class" => "TestClass",
217
- "job_id" => 123,
218
- "locale" => :en,
219
- "queue_name" => "default"
220
- )
221
- end
222
- let(:job) do
223
- double(
224
- :id => 123,
225
- :name => "ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper",
226
- :priority => 1,
227
- :attempts => 1,
228
- :queue => "default",
229
- :created_at => created_at,
230
- :run_at => run_at,
231
- :payload_object => payload_object
232
- )
233
- end
234
- let(:args) { ["activejob_argument"] }
235
-
236
- it "wraps it in a transaction with the correct params" do
237
- perform
238
-
239
- transaction = last_transaction
240
- expect(transaction).to have_namespace("background_job")
241
- expect(transaction).to have_action("TestClass#perform")
242
- expect(transaction).to_not have_error
243
- expect(transaction).to include_event("name" => "perform_job.delayed_job")
244
- expect(transaction).to include_tags(
245
- "priority" => 1,
246
- "attempts" => 1,
247
- "queue" => "default",
248
- "id" => "123"
249
- )
250
- expect(transaction).to include_params(["activejob_argument"])
251
- end
252
-
253
- context "with more complex params" do
254
- let(:args) do
255
- {
256
- :foo => "Foo",
257
- :bar => "Bar"
258
- }
259
- end
260
-
261
- it "adds the more complex arguments" do
262
- perform
263
- transaction = last_transaction
264
- expect(transaction).to have_action("TestClass#perform")
265
- expect(transaction).to include_params(
266
- "foo" => "Foo",
267
- "bar" => "Bar"
268
- )
269
- end
270
-
271
- context "with parameter filtering" do
272
- let(:options) { { :filter_parameters => ["foo"] } }
273
-
274
- it "filters selected arguments" do
275
- perform
276
- transaction = last_transaction
277
- expect(transaction).to have_action("TestClass#perform")
278
- expect(transaction).to include_params(
279
- "foo" => "[FILTERED]",
280
- "bar" => "Bar"
281
- )
282
- end
283
- end
284
- end
285
-
286
- context "with run_at in the future" do
287
- let(:run_at) { Time.parse("2017-01-01 10:01:00UTC") }
288
-
289
- it "reports queue_start with run_at time" do
290
- perform
291
-
292
- expect(last_transaction).to have_queue_start(run_at.to_i * 1000)
293
- end
294
- end
295
- end
296
- end
297
- end
298
-
299
- context "with an erroring call" do
300
- let(:error) { ExampleException.new("uh oh") }
301
- before do
302
- expect(invoked_block).to receive(:call).and_raise(error)
303
- end
304
-
305
- it "adds the error to the transaction" do
306
- expect do
307
- perform
308
- end.to raise_error(error)
309
-
310
- transaction = last_transaction
311
- expect(transaction).to have_namespace("background_job")
312
- expect(transaction).to have_action("TestClass#perform")
313
- expect(transaction).to have_error("ExampleException", "uh oh")
314
- end
315
- end
316
- end
317
-
318
- describe ".extract_value" do
319
- let(:plugin) { Appsignal::Integrations::DelayedJobPlugin }
320
-
321
- context "for a hash" do
322
- let(:hash) { { :key => "value", :bool_false => false } }
323
-
324
- context "when the key exists" do
325
- subject { plugin.extract_value(hash, :key) }
326
-
327
- it { is_expected.to eq "value" }
328
-
329
- context "when the value is false" do
330
- subject { plugin.extract_value(hash, :bool_false) }
331
-
332
- it { is_expected.to be false }
333
- end
334
- end
335
-
336
- context "when the key does not exist" do
337
- subject { plugin.extract_value(hash, :nonexistent_key) }
338
-
339
- it { is_expected.to be_nil }
340
-
341
- context "with a default value" do
342
- subject { plugin.extract_value(hash, :nonexistent_key, 1) }
343
-
344
- it { is_expected.to eq 1 }
345
- end
346
- end
347
- end
348
-
349
- context "for a struct" do
350
- before :context do
351
- TestStruct = Struct.new(:key)
352
- end
353
- let(:struct) { TestStruct.new("value") }
354
-
355
- context "when the key exists" do
356
- subject { plugin.extract_value(struct, :key) }
357
-
358
- it { is_expected.to eq "value" }
359
- end
360
-
361
- context "when the key does not exist" do
362
- subject { plugin.extract_value(struct, :nonexistent_key) }
363
-
364
- it { is_expected.to be_nil }
365
-
366
- context "with a default value" do
367
- subject { plugin.extract_value(struct, :nonexistent_key, 1) }
368
-
369
- it { is_expected.to eq 1 }
370
- end
371
- end
372
- end
373
-
374
- context "for a struct with a method" do
375
- before :context do
376
- class TestStructClass < Struct.new(:id) # rubocop:disable Style/StructInheritance
377
- def appsignal_name
378
- "TestStruct#perform"
379
- end
380
-
381
- def bool_false
382
- false
383
- end
384
- end
385
- end
386
- let(:struct) { TestStructClass.new("id") }
387
-
388
- context "when the Struct responds to a method" do
389
- subject { plugin.extract_value(struct, :appsignal_name) }
390
-
391
- it "returns the method value" do
392
- is_expected.to eq "TestStruct#perform"
393
- end
394
-
395
- context "when the value is false" do
396
- subject { plugin.extract_value(struct, :bool_false) }
397
-
398
- it "returns the method value" do
399
- is_expected.to be false
400
- end
401
- end
402
- end
403
-
404
- context "when the key does not exist" do
405
- subject { plugin.extract_value(struct, :nonexistent_key) }
406
-
407
- context "without a method with the same name" do
408
- it "returns nil" do
409
- is_expected.to be_nil
410
- end
411
- end
412
-
413
- context "with a default value" do
414
- let(:default_value) { :my_default_value }
415
- subject { plugin.extract_value(struct, :nonexistent_key, default_value) }
416
-
417
- it "returns the default value" do
418
- is_expected.to eq default_value
419
- end
420
- end
421
- end
422
- end
423
-
424
- context "for an object" do
425
- let(:object) { double(:existing_method => "value") }
426
-
427
- context "when the method exists" do
428
- subject { plugin.extract_value(object, :existing_method) }
429
-
430
- it { is_expected.to eq "value" }
431
- end
432
-
433
- context "when the method does not exist" do
434
- subject { plugin.extract_value(object, :nonexistent_method) }
435
-
436
- it { is_expected.to be_nil }
437
-
438
- context "and there is a default value" do
439
- subject { plugin.extract_value(object, :nonexistent_method, 1) }
440
-
441
- it { is_expected.to eq 1 }
442
- end
443
- end
444
- end
445
-
446
- context "when we need to call to_s on the value" do
447
- let(:object) { double(:existing_method => 1) }
448
-
449
- subject { plugin.extract_value(object, :existing_method, nil, true) }
450
-
451
- it { is_expected.to eq "1" }
452
- end
453
- end
454
- end
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if DependencyHelper.http_present?
4
- require "appsignal/integrations/http"
5
-
6
- describe Appsignal::Integrations::HttpIntegration do
7
- let(:transaction) { http_request_transaction }
8
-
9
- around do |example|
10
- keep_transactions { example.run }
11
- end
12
- before do
13
- start_agent
14
- set_current_transaction(transaction)
15
- end
16
-
17
- it "instruments a HTTP request" do
18
- stub_request(:get, "http://www.google.com")
19
-
20
- HTTP.get("http://www.google.com")
21
-
22
- expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
23
- expect(transaction).to include_event(
24
- "body" => "",
25
- "body_format" => Appsignal::EventFormatter::DEFAULT,
26
- "name" => "request.http_rb",
27
- "title" => "GET http://www.google.com"
28
- )
29
- end
30
-
31
- it "instruments a HTTPS request" do
32
- stub_request(:get, "https://www.google.com")
33
-
34
- HTTP.get("https://www.google.com")
35
-
36
- expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
37
- expect(transaction).to include_event(
38
- "body" => "",
39
- "body_format" => Appsignal::EventFormatter::DEFAULT,
40
- "name" => "request.http_rb",
41
- "title" => "GET https://www.google.com"
42
- )
43
- end
44
-
45
- context "with request parameters" do
46
- it "does not include the query parameters in the title" do
47
- stub_request(:get, "https://www.google.com?q=Appsignal")
48
-
49
- HTTP.get("https://www.google.com", :params => { :q => "Appsignal" })
50
-
51
- expect(transaction).to include_event(
52
- "body" => "",
53
- "title" => "GET https://www.google.com"
54
- )
55
- end
56
-
57
- it "does not include the request body in the title" do
58
- stub_request(:post, "https://www.google.com")
59
- .with(:body => { :q => "Appsignal" }.to_json)
60
-
61
- HTTP.post("https://www.google.com", :json => { :q => "Appsignal" })
62
-
63
- expect(transaction).to include_event(
64
- "body" => "",
65
- "title" => "POST https://www.google.com"
66
- )
67
- end
68
- end
69
-
70
- context "with various URI objects" do
71
- it "parses an object responding to #to_s" do
72
- request_uri = Struct.new(:uri) do
73
- def to_s
74
- uri.to_s
75
- end
76
- end
77
-
78
- stub_request(:get, "http://www.google.com")
79
-
80
- HTTP.get(request_uri.new("http://www.google.com"))
81
-
82
- expect(transaction).to include_event(
83
- "name" => "request.http_rb",
84
- "title" => "GET http://www.google.com"
85
- )
86
- end
87
-
88
- it "parses an URI object" do
89
- stub_request(:get, "http://www.google.com")
90
-
91
- HTTP.get(URI("http://www.google.com"))
92
-
93
- expect(transaction).to include_event(
94
- "name" => "request.http_rb",
95
- "title" => "GET http://www.google.com"
96
- )
97
- end
98
-
99
- it "parses a String object" do
100
- stub_request(:get, "http://www.google.com")
101
-
102
- HTTP.get("http://www.google.com")
103
-
104
- expect(transaction).to include_event(
105
- "name" => "request.http_rb",
106
- "title" => "GET http://www.google.com"
107
- )
108
- end
109
- end
110
- end
111
- end