appsignal 3.9.2-java → 3.9.3-java
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3135 -0
- data/.rubocop.yml +28 -20
- data/.rubocop_todo.yml +7 -33
- data/CHANGELOG.md +38 -0
- data/Rakefile +79 -64
- data/appsignal.gemspec +1 -1
- data/build_matrix.yml +109 -179
- data/ext/base.rb +1 -1
- data/gemfiles/hanami-2.1.gemfile +7 -0
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/config.rb +1 -1
- data/lib/appsignal/demo.rb +0 -1
- data/lib/appsignal/environment.rb +5 -1
- data/lib/appsignal/extension/jruby.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +1 -1
- data/lib/appsignal/integrations/grape.rb +19 -47
- data/lib/appsignal/integrations/hanami.rb +8 -7
- data/lib/appsignal/integrations/padrino.rb +46 -43
- data/lib/appsignal/integrations/railtie.rb +0 -3
- data/lib/appsignal/integrations/sinatra.rb +0 -1
- 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 +62 -28
- data/lib/appsignal/rack/event_handler.rb +12 -3
- data/lib/appsignal/rack/grape_middleware.rb +40 -0
- data/lib/appsignal/rack/hanami_middleware.rb +1 -11
- data/lib/appsignal/rack/rails_instrumentation.rb +14 -55
- 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 +34 -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 +7 -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 +9 -19
- 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 +47 -70
- 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 +0 -1
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +28 -39
- 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 +215 -106
- data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -12
- 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/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 +68 -86
- data/spec/lib/appsignal/transaction_spec.rb +76 -90
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
- data/spec/lib/appsignal_spec.rb +363 -342
- 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 +15 -10
- 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/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
|
@@ -385,6 +385,8 @@ describe Appsignal::Config do
|
|
|
385
385
|
|
|
386
386
|
context "without the selected env" do
|
|
387
387
|
let(:config) { project_fixture_config("nonsense") }
|
|
388
|
+
let(:log_stream) { std_stream }
|
|
389
|
+
let(:log) { log_contents(log_stream) }
|
|
388
390
|
|
|
389
391
|
it "is not valid or active" do
|
|
390
392
|
expect(config.valid?).to be_falsy
|
|
@@ -392,11 +394,11 @@ describe Appsignal::Config do
|
|
|
392
394
|
end
|
|
393
395
|
|
|
394
396
|
it "logs an error" do
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
use_logger_with(log_stream) { config }
|
|
398
|
+
expect(log)
|
|
399
|
+
.to contains_log(:error, "Not loading from config file: config for 'nonsense' not found")
|
|
400
|
+
expect(log)
|
|
401
|
+
.to contains_log(:error, "Push API key not set after loading config")
|
|
400
402
|
end
|
|
401
403
|
end
|
|
402
404
|
end
|
|
@@ -32,56 +32,53 @@ describe Appsignal::Demo do
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe ".create_example_error_request" do
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
before do
|
|
38
|
-
Appsignal.config = config
|
|
39
|
-
expect(Appsignal::Transaction).to receive(:new).with(
|
|
40
|
-
kind_of(String),
|
|
41
|
-
Appsignal::Transaction::HTTP_REQUEST,
|
|
42
|
-
kind_of(::Rack::Request),
|
|
43
|
-
kind_of(Hash)
|
|
44
|
-
).and_return(error_transaction)
|
|
45
|
-
end
|
|
46
|
-
subject { described_class.send(:create_example_error_request) }
|
|
35
|
+
before { start_agent }
|
|
36
|
+
around { |example| keep_transactions { example.run } }
|
|
47
37
|
|
|
48
38
|
it "sets an error" do
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
54
|
-
|
|
39
|
+
described_class.send(:create_example_error_request)
|
|
40
|
+
|
|
41
|
+
transaction = last_transaction
|
|
42
|
+
expect(transaction).to have_id
|
|
43
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
|
44
|
+
expect(transaction).to have_action("DemoController#hello")
|
|
45
|
+
expect(transaction).to have_error(
|
|
46
|
+
"Appsignal::Demo::TestError",
|
|
47
|
+
"Hello world! This is an error used for demonstration purposes."
|
|
48
|
+
)
|
|
49
|
+
expect(transaction).to include_metadata(
|
|
50
|
+
"path" => "/hello",
|
|
51
|
+
"method" => "GET",
|
|
52
|
+
"demo_sample" => "true"
|
|
53
|
+
)
|
|
54
|
+
expect(transaction).to be_completed
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
describe ".create_example_performance_request" do
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
before do
|
|
62
|
-
Appsignal.config = config
|
|
63
|
-
expect(Appsignal::Transaction).to receive(:new).with(
|
|
64
|
-
kind_of(String),
|
|
65
|
-
Appsignal::Transaction::HTTP_REQUEST,
|
|
66
|
-
kind_of(::Rack::Request),
|
|
67
|
-
kind_of(Hash)
|
|
68
|
-
).and_return(performance_transaction)
|
|
69
|
-
end
|
|
70
|
-
subject { described_class.send(:create_example_performance_request) }
|
|
59
|
+
before { start_agent }
|
|
60
|
+
around { |example| keep_transactions { example.run } }
|
|
71
61
|
|
|
72
62
|
it "sends a performance sample" do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
described_class.send(:create_example_performance_request)
|
|
64
|
+
|
|
65
|
+
transaction = last_transaction
|
|
66
|
+
expect(transaction).to have_id
|
|
67
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
|
68
|
+
expect(transaction).to have_action("DemoController#hello")
|
|
69
|
+
expect(transaction).to_not have_error
|
|
70
|
+
expect(transaction).to include_metadata(
|
|
71
|
+
"path" => "/hello",
|
|
72
|
+
"method" => "GET",
|
|
73
|
+
"demo_sample" => "true"
|
|
74
|
+
)
|
|
75
|
+
expect(transaction).to include_event(
|
|
76
|
+
"name" => "action_view.render",
|
|
77
|
+
"title" => "Render hello.html.erb",
|
|
78
|
+
"body" => "<h1>Hello world!</h1>",
|
|
79
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT
|
|
79
80
|
)
|
|
80
|
-
expect(
|
|
81
|
-
expect(performance_transaction).to receive(:set_metadata).with("method", "GET")
|
|
82
|
-
expect(performance_transaction).to receive(:set_metadata).with("demo_sample", "true")
|
|
83
|
-
expect(performance_transaction).to receive(:complete)
|
|
84
|
-
subject
|
|
81
|
+
expect(transaction).to be_completed
|
|
85
82
|
end
|
|
86
83
|
end
|
|
87
84
|
end
|
|
@@ -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
|