appsignal 3.9.2-java → 3.10.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3138 -0
- data/.rubocop.yml +28 -20
- data/.rubocop_todo.yml +7 -33
- data/CHANGELOG.md +130 -0
- data/README.md +0 -1
- data/Rakefile +80 -65
- data/appsignal.gemspec +1 -1
- data/build_matrix.yml +112 -184
- data/ext/base.rb +1 -1
- data/gemfiles/hanami-2.1.gemfile +7 -0
- data/gemfiles/webmachine1.gemfile +5 -4
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/config.rb +5 -1
- data/lib/appsignal/demo.rb +0 -1
- data/lib/appsignal/environment.rb +11 -2
- data/lib/appsignal/extension/jruby.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +164 -2
- data/lib/appsignal/hooks/active_job.rb +1 -6
- data/lib/appsignal/integrations/grape.rb +19 -47
- data/lib/appsignal/integrations/hanami.rb +8 -7
- data/lib/appsignal/integrations/padrino.rb +51 -52
- data/lib/appsignal/integrations/railtie.rb +0 -3
- data/lib/appsignal/integrations/rake.rb +46 -12
- data/lib/appsignal/integrations/sidekiq.rb +1 -11
- data/lib/appsignal/integrations/sinatra.rb +0 -1
- data/lib/appsignal/integrations/webmachine.rb +15 -9
- data/lib/appsignal/probes/gvl.rb +24 -2
- data/lib/appsignal/probes/sidekiq.rb +1 -1
- data/lib/appsignal/probes.rb +1 -1
- data/lib/appsignal/rack/abstract_middleware.rb +104 -33
- data/lib/appsignal/rack/body_wrapper.rb +143 -0
- data/lib/appsignal/rack/event_handler.rb +12 -3
- data/lib/appsignal/rack/generic_instrumentation.rb +5 -4
- data/lib/appsignal/rack/grape_middleware.rb +40 -0
- data/lib/appsignal/rack/hanami_middleware.rb +2 -12
- data/lib/appsignal/rack/instrumentation_middleware.rb +62 -0
- data/lib/appsignal/rack/rails_instrumentation.rb +14 -57
- data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -3
- data/lib/appsignal/rack/streaming_listener.rb +13 -59
- data/lib/appsignal/rack.rb +31 -0
- data/lib/appsignal/transaction.rb +50 -8
- data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
- data/lib/appsignal/utils.rb +1 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +36 -33
- data/spec/.rubocop.yml +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
- data/spec/lib/appsignal/cli/install_spec.rb +3 -3
- data/spec/lib/appsignal/config_spec.rb +8 -5
- data/spec/lib/appsignal/demo_spec.rb +38 -41
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
- data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
- data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
- data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
- data/spec/lib/appsignal/hooks/rake_spec.rb +107 -34
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
- data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
- data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
- data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
- data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
- data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
- data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
- data/spec/lib/appsignal/integrations/padrino_spec.rb +190 -163
- data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
- data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +10 -3
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +77 -40
- data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
- data/spec/lib/appsignal/probes_spec.rb +7 -4
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +302 -105
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +263 -0
- data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +70 -27
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
- data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +38 -0
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +44 -139
- data/spec/lib/appsignal/transaction_spec.rb +239 -94
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
- data/spec/lib/appsignal_spec.rb +556 -344
- data/spec/support/helpers/dependency_helper.rb +6 -1
- data/spec/support/helpers/std_streams_helper.rb +1 -1
- data/spec/support/helpers/transaction_helpers.rb +8 -0
- data/spec/support/matchers/transaction.rb +185 -0
- data/spec/support/mocks/dummy_app.rb +20 -0
- data/spec/support/shared_examples/instrument.rb +17 -12
- data/spec/support/testing.rb +18 -9
- metadata +20 -11
- data/.semaphore/semaphore.yml +0 -2347
- data/script/lint_git +0 -22
- data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
- data/spec/support/matchers/be_completed.rb +0 -5
- data/support/check_versions +0 -22
- /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
@@ -46,19 +46,12 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
46
46
|
http_request_env_with_data("action_dispatch.request_id" => request_id, :params => params)
|
47
47
|
end
|
48
48
|
let(:instance) { channel.new(connection, identifier, params) }
|
49
|
-
subject { transaction.to_h }
|
50
49
|
before do
|
51
50
|
start_agent
|
52
51
|
expect(Appsignal.active?).to be_truthy
|
53
52
|
transaction
|
54
53
|
|
55
|
-
|
56
|
-
transaction_id,
|
57
|
-
Appsignal::Transaction::ACTION_CABLE,
|
58
|
-
kind_of(ActionDispatch::Request)
|
59
|
-
)
|
60
|
-
.and_return(transaction)
|
61
|
-
allow(Appsignal::Transaction).to receive(:current).and_return(transaction)
|
54
|
+
set_current_transaction(transaction)
|
62
55
|
|
63
56
|
# Stub transmit call for subscribe/unsubscribe tests
|
64
57
|
allow(connection).to receive(:websocket)
|
@@ -70,35 +63,25 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
70
63
|
it "creates a transaction for an action" do
|
71
64
|
instance.perform_action("message" => "foo", "action" => "speak")
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
66
|
+
transaction = last_transaction
|
67
|
+
expect(transaction).to have_id(transaction_id)
|
68
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
69
|
+
expect(transaction).to have_action("MyChannel#speak")
|
70
|
+
expect(transaction).to_not have_error
|
71
|
+
expect(transaction).to include_metadata(
|
72
|
+
"method" => "websocket",
|
73
|
+
"path" => "/blog"
|
82
74
|
)
|
83
|
-
expect(
|
84
|
-
"allocation_count" => kind_of(Integer),
|
75
|
+
expect(transaction).to include_event(
|
85
76
|
"body" => "",
|
86
77
|
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
87
|
-
"child_allocation_count" => kind_of(Integer),
|
88
|
-
"child_duration" => kind_of(Float),
|
89
|
-
"child_gc_duration" => kind_of(Float),
|
90
78
|
"count" => 1,
|
91
|
-
"gc_duration" => kind_of(Float),
|
92
|
-
"start" => kind_of(Float),
|
93
|
-
"duration" => kind_of(Float),
|
94
79
|
"name" => "perform_action.action_cable",
|
95
80
|
"title" => ""
|
96
81
|
)
|
97
|
-
expect(
|
98
|
-
"
|
99
|
-
|
100
|
-
"message" => "foo"
|
101
|
-
}
|
82
|
+
expect(transaction).to include_params(
|
83
|
+
"action" => "speak",
|
84
|
+
"message" => "foo"
|
102
85
|
)
|
103
86
|
end
|
104
87
|
|
@@ -120,7 +103,7 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
120
103
|
it "uses its own internal request_id set by the subscribed callback" do
|
121
104
|
# Subscribe action, sets the request_id
|
122
105
|
instance.subscribe_to_channel
|
123
|
-
expect(transaction
|
106
|
+
expect(transaction).to have_id(transaction_id)
|
124
107
|
|
125
108
|
# Expect another transaction for the action.
|
126
109
|
# This transaction will use the same request_id as the
|
@@ -131,12 +114,9 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
131
114
|
kind_of(ActionDispatch::Request)
|
132
115
|
).and_return(action_transaction)
|
133
116
|
allow(Appsignal::Transaction).to receive(:current).and_return(action_transaction)
|
134
|
-
# Stub complete call, stops it from being cleared in the extension
|
135
|
-
# And allows us to call `#to_h` on it after it's been completed.
|
136
|
-
expect(action_transaction.ext).to receive(:complete)
|
137
117
|
|
138
118
|
instance.perform_action("message" => "foo", "action" => "speak")
|
139
|
-
expect(action_transaction
|
119
|
+
expect(action_transaction).to have_id(transaction_id)
|
140
120
|
end
|
141
121
|
end
|
142
122
|
|
@@ -158,25 +138,18 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
158
138
|
instance.perform_action("message" => "foo", "action" => "speak")
|
159
139
|
end.to raise_error(ExampleException)
|
160
140
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
)
|
170
|
-
expect(subject["error"]).to include(
|
171
|
-
"backtrace" => kind_of(String),
|
172
|
-
"name" => "ExampleException",
|
173
|
-
"message" => "oh no!"
|
141
|
+
transaction = last_transaction
|
142
|
+
expect(transaction).to have_id(transaction_id)
|
143
|
+
expect(transaction).to have_action("MyChannel#speak")
|
144
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
145
|
+
expect(transaction).to have_error("ExampleException", "oh no!")
|
146
|
+
expect(transaction).to include_metadata(
|
147
|
+
"method" => "websocket",
|
148
|
+
"path" => "/blog"
|
174
149
|
)
|
175
|
-
expect(
|
176
|
-
"
|
177
|
-
|
178
|
-
"message" => "foo"
|
179
|
-
}
|
150
|
+
expect(transaction).to include_params(
|
151
|
+
"action" => "speak",
|
152
|
+
"message" => "foo"
|
180
153
|
)
|
181
154
|
end
|
182
155
|
end
|
@@ -188,33 +161,23 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
188
161
|
it "creates a transaction for a subscription" do
|
189
162
|
instance.subscribe_to_channel
|
190
163
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
}
|
164
|
+
transaction = last_transaction
|
165
|
+
expect(transaction).to have_id(transaction_id)
|
166
|
+
expect(transaction).to have_action("MyChannel#subscribed")
|
167
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
168
|
+
expect(transaction).to_not have_error
|
169
|
+
expect(transaction).to include_metadata(
|
170
|
+
"method" => "websocket",
|
171
|
+
"path" => "/blog"
|
200
172
|
)
|
201
|
-
expect(
|
202
|
-
|
173
|
+
expect(transaction).to include_params("internal" => "true")
|
174
|
+
expect(transaction).to include_event(
|
203
175
|
"body" => "",
|
204
176
|
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
205
|
-
"child_allocation_count" => kind_of(Integer),
|
206
|
-
"child_duration" => kind_of(Float),
|
207
|
-
"child_gc_duration" => kind_of(Float),
|
208
177
|
"count" => 1,
|
209
|
-
"gc_duration" => kind_of(Float),
|
210
|
-
"start" => kind_of(Float),
|
211
|
-
"duration" => kind_of(Float),
|
212
178
|
"name" => "subscribed.action_cable",
|
213
179
|
"title" => ""
|
214
180
|
)
|
215
|
-
expect(subject["sample_data"]).to include(
|
216
|
-
"params" => { "internal" => "true" }
|
217
|
-
)
|
218
181
|
end
|
219
182
|
|
220
183
|
context "without request_id (standalone server)" do
|
@@ -226,7 +189,7 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
226
189
|
end
|
227
190
|
|
228
191
|
it "uses its own internal request_id" do
|
229
|
-
expect(
|
192
|
+
expect(last_transaction).to have_id(transaction_id)
|
230
193
|
end
|
231
194
|
end
|
232
195
|
|
@@ -248,23 +211,16 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
248
211
|
instance.subscribe_to_channel
|
249
212
|
end.to raise_error(ExampleException)
|
250
213
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
)
|
260
|
-
expect(subject["error"]).to include(
|
261
|
-
"backtrace" => kind_of(String),
|
262
|
-
"name" => "ExampleException",
|
263
|
-
"message" => "oh no!"
|
264
|
-
)
|
265
|
-
expect(subject["sample_data"]).to include(
|
266
|
-
"params" => { "internal" => "true" }
|
214
|
+
transaction = last_transaction
|
215
|
+
expect(transaction).to have_id(transaction_id)
|
216
|
+
expect(transaction).to have_action("MyChannel#subscribed")
|
217
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
218
|
+
expect(transaction).to have_error("ExampleException", "oh no!")
|
219
|
+
expect(transaction).to include_metadata(
|
220
|
+
"method" => "websocket",
|
221
|
+
"path" => "/blog"
|
267
222
|
)
|
223
|
+
expect(transaction).to include_params("internal" => "true")
|
268
224
|
end
|
269
225
|
end
|
270
226
|
|
@@ -280,33 +236,23 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
280
236
|
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
281
237
|
instance.subscribe_to_channel
|
282
238
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
}
|
239
|
+
transaction = last_transaction
|
240
|
+
expect(transaction).to have_id(transaction_id)
|
241
|
+
expect(transaction).to have_action("MyChannel#subscribed")
|
242
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
243
|
+
expect(transaction).to_not have_error
|
244
|
+
expect(transaction).to include_metadata(
|
245
|
+
"method" => "websocket",
|
246
|
+
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
292
247
|
)
|
293
|
-
expect(
|
294
|
-
|
248
|
+
expect(transaction).to include_params("internal" => "true")
|
249
|
+
expect(transaction).to include_event(
|
295
250
|
"body" => "",
|
296
251
|
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
297
|
-
"child_allocation_count" => kind_of(Integer),
|
298
|
-
"child_duration" => kind_of(Float),
|
299
|
-
"child_gc_duration" => kind_of(Float),
|
300
252
|
"count" => 1,
|
301
|
-
"gc_duration" => kind_of(Float),
|
302
|
-
"start" => kind_of(Float),
|
303
|
-
"duration" => kind_of(Float),
|
304
253
|
"name" => "subscribed.action_cable",
|
305
254
|
"title" => ""
|
306
255
|
)
|
307
|
-
expect(subject["sample_data"]).to include(
|
308
|
-
"params" => { "internal" => "true" }
|
309
|
-
)
|
310
256
|
end
|
311
257
|
end
|
312
258
|
end
|
@@ -318,33 +264,23 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
318
264
|
it "creates a transaction for a subscription" do
|
319
265
|
instance.unsubscribe_from_channel
|
320
266
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
}
|
267
|
+
transaction = last_transaction
|
268
|
+
expect(transaction).to have_id(transaction_id)
|
269
|
+
expect(transaction).to have_action("MyChannel#unsubscribed")
|
270
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
271
|
+
expect(transaction).to_not have_error
|
272
|
+
expect(transaction).to include_metadata(
|
273
|
+
"method" => "websocket",
|
274
|
+
"path" => "/blog"
|
330
275
|
)
|
331
|
-
expect(
|
332
|
-
|
276
|
+
expect(transaction).to include_params("internal" => "true")
|
277
|
+
expect(transaction).to include_event(
|
333
278
|
"body" => "",
|
334
279
|
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
335
|
-
"child_allocation_count" => kind_of(Integer),
|
336
|
-
"child_duration" => kind_of(Float),
|
337
|
-
"child_gc_duration" => kind_of(Float),
|
338
280
|
"count" => 1,
|
339
|
-
"gc_duration" => kind_of(Float),
|
340
|
-
"start" => kind_of(Float),
|
341
|
-
"duration" => kind_of(Float),
|
342
281
|
"name" => "unsubscribed.action_cable",
|
343
282
|
"title" => ""
|
344
283
|
)
|
345
|
-
expect(subject["sample_data"]).to include(
|
346
|
-
"params" => { "internal" => "true" }
|
347
|
-
)
|
348
284
|
end
|
349
285
|
|
350
286
|
context "without request_id (standalone server)" do
|
@@ -356,7 +292,7 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
356
292
|
end
|
357
293
|
|
358
294
|
it "uses its own internal request_id" do
|
359
|
-
expect(
|
295
|
+
expect(transaction).to have_id(transaction_id)
|
360
296
|
end
|
361
297
|
end
|
362
298
|
|
@@ -378,23 +314,16 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
378
314
|
instance.unsubscribe_from_channel
|
379
315
|
end.to raise_error(ExampleException)
|
380
316
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
)
|
390
|
-
expect(subject["error"]).to include(
|
391
|
-
"backtrace" => kind_of(String),
|
392
|
-
"name" => "ExampleException",
|
393
|
-
"message" => "oh no!"
|
394
|
-
)
|
395
|
-
expect(subject["sample_data"]).to include(
|
396
|
-
"params" => { "internal" => "true" }
|
317
|
+
transaction = last_transaction
|
318
|
+
expect(transaction).to have_id(transaction_id)
|
319
|
+
expect(transaction).to have_action("MyChannel#unsubscribed")
|
320
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
321
|
+
expect(transaction).to have_error("ExampleException", "oh no!")
|
322
|
+
expect(transaction).to include_metadata(
|
323
|
+
"method" => "websocket",
|
324
|
+
"path" => "/blog"
|
397
325
|
)
|
326
|
+
expect(transaction).to include_params("internal" => "true")
|
398
327
|
end
|
399
328
|
end
|
400
329
|
|
@@ -410,33 +339,23 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
410
339
|
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
411
340
|
instance.unsubscribe_from_channel
|
412
341
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
}
|
342
|
+
transaction = last_transaction
|
343
|
+
expect(transaction).to have_id(transaction_id)
|
344
|
+
expect(transaction).to have_action("MyChannel#unsubscribed")
|
345
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
346
|
+
expect(transaction).to_not have_error
|
347
|
+
expect(transaction).to include_metadata(
|
348
|
+
"method" => "websocket",
|
349
|
+
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
422
350
|
)
|
423
|
-
expect(
|
424
|
-
|
351
|
+
expect(transaction).to include_params("internal" => "true")
|
352
|
+
expect(transaction).to include_event(
|
425
353
|
"body" => "",
|
426
354
|
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
427
|
-
"child_allocation_count" => kind_of(Integer),
|
428
|
-
"child_duration" => kind_of(Float),
|
429
|
-
"child_gc_duration" => kind_of(Float),
|
430
355
|
"count" => 1,
|
431
|
-
"gc_duration" => kind_of(Float),
|
432
|
-
"start" => kind_of(Float),
|
433
|
-
"duration" => kind_of(Float),
|
434
356
|
"name" => "unsubscribed.action_cable",
|
435
357
|
"title" => ""
|
436
358
|
)
|
437
|
-
expect(subject["sample_data"]).to include(
|
438
|
-
"params" => { "internal" => "true" }
|
439
|
-
)
|
440
359
|
end
|
441
360
|
end
|
442
361
|
end
|
data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
CHANGED
@@ -5,31 +5,19 @@ shared_examples "activesupport finish_with_state override" do
|
|
5
5
|
listeners_state = instrumenter.start("sql.active_record", {})
|
6
6
|
instrumenter.finish_with_state(listeners_state, "sql.active_record", :sql => "SQL")
|
7
7
|
|
8
|
-
expect(transaction
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
"child_gc_duration" => kind_of(Float),
|
16
|
-
"count" => 1,
|
17
|
-
"duration" => kind_of(Float),
|
18
|
-
"gc_duration" => kind_of(Float),
|
19
|
-
"name" => "sql.active_record",
|
20
|
-
"start" => kind_of(Float),
|
21
|
-
"title" => ""
|
22
|
-
}
|
23
|
-
])
|
8
|
+
expect(transaction).to include_event(
|
9
|
+
"body" => "SQL",
|
10
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
11
|
+
"count" => 1,
|
12
|
+
"name" => "sql.active_record",
|
13
|
+
"title" => ""
|
14
|
+
)
|
24
15
|
end
|
25
16
|
|
26
17
|
it "does not instrument events whose name starts with a bang" do
|
27
|
-
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
28
|
-
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
29
|
-
|
30
18
|
listeners_state = instrumenter.start("!sql.active_record", {})
|
31
19
|
instrumenter.finish_with_state(listeners_state, "!sql.active_record", :sql => "SQL")
|
32
20
|
|
33
|
-
expect(transaction
|
21
|
+
expect(transaction).to_not include_events
|
34
22
|
end
|
35
23
|
end
|
@@ -5,22 +5,13 @@ shared_examples "activesupport instrument override" do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
expect(return_value).to eq "value"
|
8
|
-
expect(transaction
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
"child_gc_duration" => kind_of(Float),
|
16
|
-
"count" => 1,
|
17
|
-
"duration" => kind_of(Float),
|
18
|
-
"gc_duration" => kind_of(Float),
|
19
|
-
"name" => "sql.active_record",
|
20
|
-
"start" => kind_of(Float),
|
21
|
-
"title" => ""
|
22
|
-
}
|
23
|
-
])
|
8
|
+
expect(transaction).to include_event(
|
9
|
+
"body" => "SQL",
|
10
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
11
|
+
"count" => 1,
|
12
|
+
"name" => "sql.active_record",
|
13
|
+
"title" => ""
|
14
|
+
)
|
24
15
|
end
|
25
16
|
|
26
17
|
it "instruments an ActiveSupport::Notifications.instrument event with no registered formatter" do
|
@@ -29,53 +20,34 @@ shared_examples "activesupport instrument override" do
|
|
29
20
|
end
|
30
21
|
|
31
22
|
expect(return_value).to eq "value"
|
32
|
-
expect(transaction
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
"child_gc_duration" => kind_of(Float),
|
40
|
-
"count" => 1,
|
41
|
-
"duration" => kind_of(Float),
|
42
|
-
"gc_duration" => kind_of(Float),
|
43
|
-
"name" => "no-registered.formatter",
|
44
|
-
"start" => kind_of(Float),
|
45
|
-
"title" => ""
|
46
|
-
}
|
47
|
-
])
|
23
|
+
expect(transaction).to include_event(
|
24
|
+
"body" => "",
|
25
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
26
|
+
"count" => 1,
|
27
|
+
"name" => "no-registered.formatter",
|
28
|
+
"title" => ""
|
29
|
+
)
|
48
30
|
end
|
49
31
|
|
50
32
|
it "converts non-string names to strings" do
|
51
33
|
as.instrument(:not_a_string) {} # rubocop:disable Lint/EmptyBlock
|
52
|
-
expect(transaction
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"child_gc_duration" => kind_of(Float),
|
60
|
-
"count" => 1,
|
61
|
-
"duration" => kind_of(Float),
|
62
|
-
"gc_duration" => kind_of(Float),
|
63
|
-
"name" => "not_a_string",
|
64
|
-
"start" => kind_of(Float),
|
65
|
-
"title" => ""
|
66
|
-
}
|
67
|
-
])
|
34
|
+
expect(transaction).to include_event(
|
35
|
+
"body" => "",
|
36
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
37
|
+
"count" => 1,
|
38
|
+
"name" => "not_a_string",
|
39
|
+
"title" => ""
|
40
|
+
)
|
68
41
|
end
|
69
42
|
|
70
43
|
it "does not instrument events whose name starts with a bang" do
|
71
|
-
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
72
|
-
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
73
|
-
|
74
44
|
return_value = as.instrument("!sql.active_record", :sql => "SQL") do
|
75
45
|
"value"
|
76
46
|
end
|
77
47
|
|
78
48
|
expect(return_value).to eq "value"
|
49
|
+
|
50
|
+
expect(transaction).to_not include_events
|
79
51
|
end
|
80
52
|
|
81
53
|
context "when an error is raised in an instrumented block" do
|
@@ -86,22 +58,13 @@ shared_examples "activesupport instrument override" do
|
|
86
58
|
end
|
87
59
|
end.to raise_error(ExampleException, "foo")
|
88
60
|
|
89
|
-
expect(transaction
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
"child_gc_duration" => kind_of(Float),
|
97
|
-
"count" => 1,
|
98
|
-
"duration" => kind_of(Float),
|
99
|
-
"gc_duration" => kind_of(Float),
|
100
|
-
"name" => "sql.active_record",
|
101
|
-
"start" => kind_of(Float),
|
102
|
-
"title" => ""
|
103
|
-
}
|
104
|
-
])
|
61
|
+
expect(transaction).to include_event(
|
62
|
+
"body" => "SQL",
|
63
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
64
|
+
"count" => 1,
|
65
|
+
"name" => "sql.active_record",
|
66
|
+
"title" => ""
|
67
|
+
)
|
105
68
|
end
|
106
69
|
end
|
107
70
|
|
@@ -113,22 +76,13 @@ shared_examples "activesupport instrument override" do
|
|
113
76
|
end
|
114
77
|
end.to throw_symbol(:foo)
|
115
78
|
|
116
|
-
expect(transaction
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
"child_gc_duration" => kind_of(Float),
|
124
|
-
"count" => 1,
|
125
|
-
"duration" => kind_of(Float),
|
126
|
-
"gc_duration" => kind_of(Float),
|
127
|
-
"name" => "sql.active_record",
|
128
|
-
"start" => kind_of(Float),
|
129
|
-
"title" => ""
|
130
|
-
}
|
131
|
-
])
|
79
|
+
expect(transaction).to include_event(
|
80
|
+
"body" => "SQL",
|
81
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
82
|
+
"count" => 1,
|
83
|
+
"name" => "sql.active_record",
|
84
|
+
"title" => ""
|
85
|
+
)
|
132
86
|
end
|
133
87
|
end
|
134
88
|
|
@@ -139,7 +93,7 @@ shared_examples "activesupport instrument override" do
|
|
139
93
|
Appsignal::Transaction.complete_current!
|
140
94
|
end
|
141
95
|
|
142
|
-
expect(transaction
|
96
|
+
expect(transaction).to_not include_events
|
143
97
|
end
|
144
98
|
end
|
145
99
|
end
|