appsignal 2.11.6 → 2.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/appsignal/hooks/action_cable.rb +10 -2
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +88 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45f78817cdaaf759d7bb0fd3109cb6a16557956b485f3c245a524651301de9fc
|
4
|
+
data.tar.gz: ca75043dbd897e34817fd24879be0c95fda398c06d1b8a73863da86847eb1f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cc2e5f99efd70c3e1e53d1a14cccc6c3373a4aded2ef75b1b3112c6def42dfbf3114e05fd06bfadcf558c0bd4b5e1ebf027e5d258565a94d6f7562c1bfe66d
|
7
|
+
data.tar.gz: 88fb1e14b251c8188b45dd4594f65c849bbaa25333434b55353749c424b9d387dfd83c358947a46cdde1ace806c6da0117e99567a601111c4b8d77468826c4f5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 2.11.7
|
4
|
+
- Fix ActionCable integration in test environment using `stub_connection`.
|
5
|
+
PR #705
|
6
|
+
|
3
7
|
# 2.11.6
|
4
8
|
- Prepend Sidekiq middleware to wrap all Sidekiq middleware. Catches more
|
5
9
|
errors and provide more complete performance measurements. PR #698
|
@@ -56,7 +56,11 @@ module Appsignal
|
|
56
56
|
def install_callbacks
|
57
57
|
ActionCable::Channel::Base.set_callback :subscribe, :around, :prepend => true do |channel, inner|
|
58
58
|
# The request is only the original websocket request
|
59
|
-
|
59
|
+
connection = channel.connection
|
60
|
+
# #env is not available on the Rails ConnectionStub class used in the
|
61
|
+
# Rails app test suite. If we call `#env` it causes an error to occur
|
62
|
+
# in apps' test suites.
|
63
|
+
env = connection.respond_to?(:env) ? connection.env : {}
|
60
64
|
request = ActionDispatch::Request.new(env)
|
61
65
|
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
|
62
66
|
request.request_id || SecureRandom.uuid
|
@@ -84,7 +88,11 @@ module Appsignal
|
|
84
88
|
|
85
89
|
ActionCable::Channel::Base.set_callback :unsubscribe, :around, :prepend => true do |channel, inner|
|
86
90
|
# The request is only the original websocket request
|
87
|
-
|
91
|
+
connection = channel.connection
|
92
|
+
# #env is not available on the Rails ConnectionStub class used in the
|
93
|
+
# Rails app test suite. If we call `#env` it causes an error to occur
|
94
|
+
# in apps' test suites.
|
95
|
+
env = connection.respond_to?(:env) ? connection.env : {}
|
88
96
|
request = ActionDispatch::Request.new(env)
|
89
97
|
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
|
90
98
|
request.request_id || SecureRandom.uuid
|
data/lib/appsignal/version.rb
CHANGED
@@ -2,6 +2,8 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
2
2
|
if DependencyHelper.action_cable_present?
|
3
3
|
context "with ActionCable" do
|
4
4
|
require "action_cable/engine"
|
5
|
+
# Require test helper to test with ConnectionStub
|
6
|
+
require "action_cable/channel/test_case" if DependencyHelper.rails6_present?
|
5
7
|
|
6
8
|
describe ".dependencies_present?" do
|
7
9
|
subject { described_class.new.dependencies_present? }
|
@@ -262,6 +264,49 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
262
264
|
)
|
263
265
|
end
|
264
266
|
end
|
267
|
+
|
268
|
+
if DependencyHelper.rails6_present?
|
269
|
+
context "with ConnectionStub" do
|
270
|
+
let(:connection) { ActionCable::Channel::ConnectionStub.new }
|
271
|
+
let(:transaction_id) { "Stubbed transaction id" }
|
272
|
+
before do
|
273
|
+
# Stub future (private AppSignal) transaction id generated by the hook.
|
274
|
+
expect(SecureRandom).to receive(:uuid).and_return(transaction_id)
|
275
|
+
end
|
276
|
+
|
277
|
+
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
278
|
+
instance.subscribe_to_channel
|
279
|
+
|
280
|
+
expect(subject).to include(
|
281
|
+
"action" => "MyChannel#subscribed",
|
282
|
+
"error" => nil,
|
283
|
+
"id" => transaction_id,
|
284
|
+
"namespace" => Appsignal::Transaction::ACTION_CABLE,
|
285
|
+
"metadata" => {
|
286
|
+
"method" => "websocket",
|
287
|
+
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
288
|
+
}
|
289
|
+
)
|
290
|
+
expect(subject["events"].first).to include(
|
291
|
+
"allocation_count" => kind_of(Integer),
|
292
|
+
"body" => "",
|
293
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
294
|
+
"child_allocation_count" => kind_of(Integer),
|
295
|
+
"child_duration" => kind_of(Float),
|
296
|
+
"child_gc_duration" => kind_of(Float),
|
297
|
+
"count" => 1,
|
298
|
+
"gc_duration" => kind_of(Float),
|
299
|
+
"start" => kind_of(Float),
|
300
|
+
"duration" => kind_of(Float),
|
301
|
+
"name" => "subscribed.action_cable",
|
302
|
+
"title" => ""
|
303
|
+
)
|
304
|
+
expect(subject["sample_data"]).to include(
|
305
|
+
"params" => { "internal" => "true" }
|
306
|
+
)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
265
310
|
end
|
266
311
|
|
267
312
|
describe "unsubscribe callback" do
|
@@ -349,6 +394,49 @@ describe Appsignal::Hooks::ActionCableHook do
|
|
349
394
|
)
|
350
395
|
end
|
351
396
|
end
|
397
|
+
|
398
|
+
if DependencyHelper.rails6_present?
|
399
|
+
context "with ConnectionStub" do
|
400
|
+
let(:connection) { ActionCable::Channel::ConnectionStub.new }
|
401
|
+
let(:transaction_id) { "Stubbed transaction id" }
|
402
|
+
before do
|
403
|
+
# Stub future (private AppSignal) transaction id generated by the hook.
|
404
|
+
expect(SecureRandom).to receive(:uuid).and_return(transaction_id)
|
405
|
+
end
|
406
|
+
|
407
|
+
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
408
|
+
instance.unsubscribe_from_channel
|
409
|
+
|
410
|
+
expect(subject).to include(
|
411
|
+
"action" => "MyChannel#unsubscribed",
|
412
|
+
"error" => nil,
|
413
|
+
"id" => transaction_id,
|
414
|
+
"namespace" => Appsignal::Transaction::ACTION_CABLE,
|
415
|
+
"metadata" => {
|
416
|
+
"method" => "websocket",
|
417
|
+
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
418
|
+
}
|
419
|
+
)
|
420
|
+
expect(subject["events"].first).to include(
|
421
|
+
"allocation_count" => kind_of(Integer),
|
422
|
+
"body" => "",
|
423
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
424
|
+
"child_allocation_count" => kind_of(Integer),
|
425
|
+
"child_duration" => kind_of(Float),
|
426
|
+
"child_gc_duration" => kind_of(Float),
|
427
|
+
"count" => 1,
|
428
|
+
"gc_duration" => kind_of(Float),
|
429
|
+
"start" => kind_of(Float),
|
430
|
+
"duration" => kind_of(Float),
|
431
|
+
"name" => "unsubscribed.action_cable",
|
432
|
+
"title" => ""
|
433
|
+
)
|
434
|
+
expect(subject["sample_data"]).to include(
|
435
|
+
"params" => { "internal" => "true" }
|
436
|
+
)
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
352
440
|
end
|
353
441
|
end
|
354
442
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-02-
|
13
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -418,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
418
418
|
- !ruby/object:Gem::Version
|
419
419
|
version: '0'
|
420
420
|
requirements: []
|
421
|
-
rubygems_version: 3.2.
|
421
|
+
rubygems_version: 3.2.8
|
422
422
|
signing_key:
|
423
423
|
specification_version: 4
|
424
424
|
summary: Logs performance and exception data from your app to appsignal.com
|