appsignal 3.11.0 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +115 -0
- data/Rakefile +1 -1
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/config.rb +150 -32
- data/lib/appsignal/demo.rb +1 -6
- data/lib/appsignal/helpers/instrumentation.rb +2 -2
- data/lib/appsignal/integrations/grape.rb +7 -0
- data/lib/appsignal/integrations/hanami.rb +8 -43
- data/lib/appsignal/integrations/padrino.rb +8 -73
- data/lib/appsignal/integrations/railtie.rb +35 -13
- data/lib/appsignal/integrations/sinatra.rb +8 -19
- data/lib/appsignal/loaders/grape.rb +13 -0
- data/lib/appsignal/loaders/hanami.rb +40 -0
- data/lib/appsignal/loaders/padrino.rb +68 -0
- data/lib/appsignal/loaders/sinatra.rb +24 -0
- data/lib/appsignal/loaders.rb +92 -0
- data/lib/appsignal/rack/abstract_middleware.rb +2 -1
- data/lib/appsignal/rack/event_handler.rb +5 -5
- data/lib/appsignal/rack.rb +6 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +163 -9
- data/spec/lib/appsignal/cli/demo_spec.rb +0 -1
- data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1
- data/spec/lib/appsignal/config_spec.rb +153 -1
- data/spec/lib/appsignal/demo_spec.rb +1 -2
- data/spec/lib/appsignal/environment_spec.rb +4 -2
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/activejob_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +4 -7
- data/spec/lib/appsignal/hooks/excon_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/gvl_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/http_spec.rb +1 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -8
- data/spec/lib/appsignal/hooks/redis_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/resque_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/sequel_spec.rb +3 -5
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/grape_spec.rb +36 -0
- data/spec/lib/appsignal/integrations/hanami_spec.rb +9 -178
- data/spec/lib/appsignal/integrations/http_spec.rb +1 -5
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +4 -2
- data/spec/lib/appsignal/integrations/net_http_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/object_spec.rb +1 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -330
- data/spec/lib/appsignal/integrations/railtie_spec.rb +275 -191
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +11 -9
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +9 -104
- data/spec/lib/appsignal/loaders/grape_spec.rb +12 -0
- data/spec/lib/appsignal/loaders/hanami_spec.rb +95 -0
- data/spec/lib/appsignal/loaders/padrino_spec.rb +277 -0
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +47 -0
- data/spec/lib/appsignal/loaders_spec.rb +137 -0
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +1 -1
- data/spec/lib/appsignal/probes_spec.rb +6 -5
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +3 -2
- data/spec/lib/appsignal/rack/event_handler_spec.rb +33 -0
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +1 -1
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +2 -35
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +1 -1
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +3 -3
- data/spec/lib/appsignal/span_spec.rb +1 -3
- data/spec/lib/appsignal/transaction_spec.rb +61 -70
- data/spec/lib/appsignal_spec.rb +284 -26
- data/spec/lib/puma/appsignal_spec.rb +0 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/helpers/config_helpers.rb +2 -1
- data/spec/support/helpers/loader_helper.rb +21 -0
- data/spec/support/matchers/transaction.rb +3 -2
- data/spec/support/stubs/appsignal/loaders/loader_stub.rb +7 -0
- data/spec/support/testing.rb +46 -0
- metadata +15 -2
@@ -6,59 +6,121 @@ if DependencyHelper.rails_present?
|
|
6
6
|
|
7
7
|
after { clear_rails_error_reporter! }
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
module RailtieHelper
|
10
|
+
def self.ensure_initialize!
|
11
|
+
return if @initialized
|
12
12
|
|
13
|
-
MyApp::Application.config.root = project_fixture_path
|
13
|
+
MyApp::Application.config.root = ConfigHelpers.project_fixture_path
|
14
14
|
MyApp::Application.initialize!
|
15
|
+
@initialized = true
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def expect_middleware_to_match(middleware, klass, args)
|
20
|
+
expect(middleware.klass).to eq(klass)
|
21
|
+
expect(middleware.args).to match(args)
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
describe "on Rails app initialize!" do
|
25
|
+
it "starts AppSignal by calling its hooks" do
|
26
|
+
expect(Appsignal::Integrations::Railtie).to receive(:on_load).and_call_original
|
27
|
+
expect(Appsignal::Integrations::Railtie).to receive(:after_initialize).and_call_original
|
24
28
|
|
25
|
-
|
29
|
+
RailtieHelper.ensure_initialize!
|
26
30
|
end
|
31
|
+
end
|
27
32
|
|
28
|
-
|
29
|
-
|
33
|
+
describe "initializer" do
|
34
|
+
let(:app) { MyApp::Application.new }
|
35
|
+
before do
|
36
|
+
RailtieHelper.ensure_initialize!
|
37
|
+
Appsignal.config = nil
|
38
|
+
end
|
30
39
|
|
31
|
-
|
32
|
-
|
40
|
+
def initialize_railtie(event)
|
41
|
+
MyApp::Application.config.root = project_fixture_path
|
42
|
+
case event
|
43
|
+
when :on_load
|
44
|
+
described_class.on_load(app)
|
45
|
+
when :after_initialize
|
46
|
+
described_class.after_initialize(app)
|
47
|
+
else
|
48
|
+
raise "Unsupported test event '#{event}'"
|
49
|
+
end
|
50
|
+
end
|
33
51
|
|
34
|
-
|
52
|
+
shared_examples "integrates with Rails" do
|
53
|
+
it "starts AppSignal" do
|
54
|
+
initialize_railtie(event)
|
35
55
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
56
|
+
expect(Appsignal.active?).to be_truthy
|
57
|
+
end
|
39
58
|
|
40
|
-
|
41
|
-
|
42
|
-
|
59
|
+
it "doesn't overwrite the config if a config is already present " do
|
60
|
+
Appsignal.config = Appsignal::Config.new(
|
61
|
+
Dir.pwd,
|
62
|
+
"my_env",
|
63
|
+
:some_config => "some value"
|
64
|
+
)
|
65
|
+
initialize_railtie(event)
|
43
66
|
|
44
|
-
|
45
|
-
|
46
|
-
|
67
|
+
expect(Appsignal.config.env).to eq("my_env")
|
68
|
+
expect(Appsignal.config.root_path).to eq(Dir.pwd)
|
69
|
+
expect(Appsignal.config[:some_config]).to eq("some value")
|
70
|
+
end
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
72
|
+
it "sets the detected environment" do
|
73
|
+
initialize_railtie(event)
|
74
|
+
|
75
|
+
expect(Appsignal.config.env).to eq("test")
|
51
76
|
end
|
52
77
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
Appsignal::Integrations::Railtie.initialize_appsignal(app)
|
57
|
-
end
|
78
|
+
it "uses the APPSIGNAL_APP_ENV environment variable value as the environment" do
|
79
|
+
ENV["APPSIGNAL_APP_ENV"] = "env_test"
|
80
|
+
initialize_railtie(event)
|
58
81
|
|
59
|
-
|
60
|
-
|
61
|
-
|
82
|
+
expect(Appsignal.config.env).to eq "env_test"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "sets the Rails app path as root_path" do
|
86
|
+
initialize_railtie(event)
|
87
|
+
|
88
|
+
expect(Appsignal.config.root_path).to eq(Pathname.new(project_fixture_path))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "loads the Rails app name in the initial config" do
|
92
|
+
initialize_railtie(event)
|
93
|
+
|
94
|
+
expect(Appsignal.config.initial_config[:name]).to eq "MyApp"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "loads the app name from the project's appsignal.yml file" do
|
98
|
+
initialize_railtie(event)
|
99
|
+
|
100
|
+
expect(Appsignal.config[:name]).to eq "TestApp"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "sets the log_path based on the root_path" do
|
104
|
+
initialize_railtie(event)
|
105
|
+
|
106
|
+
expect(Appsignal.config[:log_path])
|
107
|
+
.to eq(Pathname.new(File.join(project_fixture_path, "log")))
|
108
|
+
end
|
109
|
+
|
110
|
+
it "adds the middleware" do
|
111
|
+
initialize_railtie(event)
|
112
|
+
|
113
|
+
middlewares = MyApp::Application.middleware
|
114
|
+
expect_middleware_to_match(
|
115
|
+
middlewares.find { |m| m.klass == ::Rack::Events },
|
116
|
+
::Rack::Events,
|
117
|
+
[[instance_of(Appsignal::Rack::EventHandler)]]
|
118
|
+
)
|
119
|
+
expect_middleware_to_match(
|
120
|
+
middlewares.find { |m| m.klass == Appsignal::Rack::RailsInstrumentation },
|
121
|
+
Appsignal::Rack::RailsInstrumentation,
|
122
|
+
[]
|
123
|
+
)
|
62
124
|
end
|
63
125
|
|
64
126
|
if Rails.respond_to?(:error)
|
@@ -82,7 +144,7 @@ if DependencyHelper.rails_present?
|
|
82
144
|
|
83
145
|
context "when enable_rails_error_reporter is enabled" do
|
84
146
|
it "subscribes to the error reporter" do
|
85
|
-
|
147
|
+
initialize_railtie(event)
|
86
148
|
|
87
149
|
expect(error_reporter.subscribers)
|
88
150
|
.to eq([Appsignal::Integrations::RailsErrorReporterSubscriber])
|
@@ -92,7 +154,7 @@ if DependencyHelper.rails_present?
|
|
92
154
|
context "when enable_rails_error_reporter is disabled" do
|
93
155
|
it "does not subscribe to the error reporter" do
|
94
156
|
ENV["APPSIGNAL_ENABLE_RAILS_ERROR_REPORTER"] = "false"
|
95
|
-
|
157
|
+
initialize_railtie(event)
|
96
158
|
|
97
159
|
expect(error_reporter.subscribers)
|
98
160
|
.to_not eq([Appsignal::Integrations::RailsErrorReporterSubscriber])
|
@@ -102,215 +164,237 @@ if DependencyHelper.rails_present?
|
|
102
164
|
else
|
103
165
|
context "when Rails does not listen to `error`" do
|
104
166
|
it "does not error trying to subscribe to the error reporter" do
|
105
|
-
|
167
|
+
initialize_railtie(event)
|
106
168
|
end
|
107
169
|
end
|
108
170
|
end
|
109
171
|
end
|
110
172
|
|
111
|
-
describe ".
|
112
|
-
|
113
|
-
let(:config) { Appsignal.config.initial_config }
|
173
|
+
describe ".on_load" do
|
174
|
+
let(:event) { :on_load }
|
114
175
|
|
115
|
-
|
116
|
-
|
176
|
+
context "when start_at == :on_load" do
|
177
|
+
include_examples "integrates with Rails"
|
117
178
|
end
|
118
|
-
end
|
119
179
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
180
|
+
context "when start_at == :after_initialize" do
|
181
|
+
it "does not start AppSignal" do
|
182
|
+
app.config.appsignal.start_at = :after_initialize
|
183
|
+
initialize_railtie(event)
|
184
|
+
|
185
|
+
expect(Appsignal.active?).to be_falsy
|
186
|
+
expect(Appsignal.config).to be_nil
|
187
|
+
end
|
127
188
|
end
|
128
189
|
end
|
129
190
|
|
130
|
-
|
131
|
-
|
132
|
-
before { start_agent }
|
133
|
-
around { |example| keep_transactions { example.run } }
|
191
|
+
describe ".after_initialize" do
|
192
|
+
let(:event) { :after_initialize }
|
134
193
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
194
|
+
context "when start_at == :after_initialize" do
|
195
|
+
before do
|
196
|
+
app.config.appsignal.start_at = :after_initialize
|
197
|
+
end
|
198
|
+
|
199
|
+
include_examples "integrates with Rails"
|
200
|
+
end
|
201
|
+
|
202
|
+
context "when start_at == :on_load" do
|
203
|
+
it "does not start AppSignal" do
|
204
|
+
app.config.appsignal.start_at = :on_load
|
205
|
+
initialize_railtie(event)
|
142
206
|
|
143
|
-
|
207
|
+
expect(Appsignal.active?).to be_falsy
|
208
|
+
expect(Appsignal.config).to be_nil
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
if Rails.respond_to?(:error)
|
215
|
+
describe "Rails error reporter" do
|
216
|
+
before { start_agent }
|
217
|
+
around { |example| keep_transactions { example.run } }
|
218
|
+
|
219
|
+
context "when error is not handled (reraises the error)" do
|
220
|
+
it "does nothing" do
|
221
|
+
with_rails_error_reporter do
|
222
|
+
expect do
|
223
|
+
Rails.error.record { raise ExampleStandardError, "error message" }
|
224
|
+
end.to raise_error(ExampleStandardError, "error message")
|
144
225
|
end
|
226
|
+
|
227
|
+
expect(created_transactions).to be_empty
|
145
228
|
end
|
229
|
+
end
|
146
230
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
with_rails_error_reporter do
|
158
|
-
with_current_transaction current_transaction do
|
159
|
-
Rails.error.handle { raise ExampleStandardError, "error message" }
|
160
|
-
|
161
|
-
transaction = last_transaction
|
162
|
-
expect(transaction).to have_namespace("custom")
|
163
|
-
expect(transaction).to have_action("CustomAction")
|
164
|
-
expect(transaction).to have_error("ExampleStandardError", "error message")
|
165
|
-
expect(transaction).to include_tags(
|
166
|
-
"duplicated_tag" => "duplicated value",
|
167
|
-
"severity" => "warning"
|
168
|
-
)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
231
|
+
context "when error is handled (not reraised)" do
|
232
|
+
context "when a transaction is active" do
|
233
|
+
it "duplicates the transaction namespace, action and tags" do
|
234
|
+
current_transaction = http_request_transaction
|
235
|
+
current_transaction.set_namespace "custom"
|
236
|
+
current_transaction.set_action "CustomAction"
|
237
|
+
current_transaction.set_tags(
|
238
|
+
:duplicated_tag => "duplicated value"
|
239
|
+
)
|
172
240
|
|
173
|
-
|
174
|
-
current_transaction
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
"severity" => "warning"
|
186
|
-
)
|
187
|
-
end
|
241
|
+
with_rails_error_reporter do
|
242
|
+
with_current_transaction current_transaction do
|
243
|
+
Rails.error.handle { raise ExampleStandardError, "error message" }
|
244
|
+
|
245
|
+
transaction = last_transaction
|
246
|
+
expect(transaction).to have_namespace("custom")
|
247
|
+
expect(transaction).to have_action("CustomAction")
|
248
|
+
expect(transaction).to have_error("ExampleStandardError", "error message")
|
249
|
+
expect(transaction).to include_tags(
|
250
|
+
"duplicated_tag" => "duplicated value",
|
251
|
+
"severity" => "warning"
|
252
|
+
)
|
188
253
|
end
|
189
254
|
end
|
255
|
+
end
|
190
256
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
transaction = last_transaction
|
207
|
-
expect(transaction).to include_custom_data(
|
208
|
-
"array" => [1, 2],
|
209
|
-
"hash" => { "one" => 1, "two" => 2 }
|
210
|
-
)
|
211
|
-
end
|
257
|
+
it "overwrites duplicated tags with tags from context" do
|
258
|
+
current_transaction = http_request_transaction
|
259
|
+
current_transaction.set_tags(:tag1 => "duplicated value")
|
260
|
+
|
261
|
+
with_rails_error_reporter do
|
262
|
+
with_current_transaction current_transaction do
|
263
|
+
given_context = { :tag1 => "value1", :tag2 => "value2" }
|
264
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
265
|
+
|
266
|
+
expect(last_transaction).to include_tags(
|
267
|
+
"tag1" => "value1",
|
268
|
+
"tag2" => "value2",
|
269
|
+
"severity" => "warning"
|
270
|
+
)
|
212
271
|
end
|
213
272
|
end
|
273
|
+
end
|
214
274
|
|
215
|
-
|
216
|
-
|
217
|
-
current_transaction.set_namespace "custom"
|
218
|
-
current_transaction.set_action "CustomAction"
|
275
|
+
it "sends tags stored in :appsignal -> :custom_data as custom data" do
|
276
|
+
current_transaction = http_request_transaction
|
219
277
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
278
|
+
with_rails_error_reporter do
|
279
|
+
with_current_transaction current_transaction do
|
280
|
+
given_context = {
|
281
|
+
:appsignal => {
|
282
|
+
:custom_data => {
|
283
|
+
:array => [1, 2],
|
284
|
+
:hash => { :one => 1, :two => 2 }
|
285
|
+
}
|
224
286
|
}
|
225
|
-
|
287
|
+
}
|
288
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
226
289
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
290
|
+
transaction = last_transaction
|
291
|
+
expect(transaction).to include_custom_data(
|
292
|
+
"array" => [1, 2],
|
293
|
+
"hash" => { "one" => 1, "two" => 2 }
|
294
|
+
)
|
231
295
|
end
|
232
296
|
end
|
233
297
|
end
|
234
298
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
end
|
299
|
+
it "overwrites duplicated namespace and action with custom from context" do
|
300
|
+
current_transaction = http_request_transaction
|
301
|
+
current_transaction.set_namespace "custom"
|
302
|
+
current_transaction.set_action "CustomAction"
|
240
303
|
|
241
|
-
|
242
|
-
|
243
|
-
|
304
|
+
with_rails_error_reporter do
|
305
|
+
with_current_transaction current_transaction do
|
306
|
+
given_context = {
|
307
|
+
:appsignal => { :namespace => "context", :action => "ContextAction" }
|
308
|
+
}
|
309
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
244
310
|
|
245
|
-
|
246
|
-
|
311
|
+
transaction = last_transaction
|
312
|
+
expect(transaction).to have_namespace("context")
|
313
|
+
expect(transaction).to have_action("ContextAction")
|
247
314
|
end
|
248
315
|
end
|
316
|
+
end
|
317
|
+
end
|
249
318
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
319
|
+
context "when no transaction is active" do
|
320
|
+
class ExampleRailsRequestMock
|
321
|
+
def path
|
322
|
+
"path"
|
323
|
+
end
|
254
324
|
|
255
|
-
|
256
|
-
|
257
|
-
end
|
325
|
+
def method
|
326
|
+
"GET"
|
258
327
|
end
|
259
328
|
|
260
|
-
|
329
|
+
def filtered_parameters
|
330
|
+
{ :user_id => 123, :password => "[FILTERED]" }
|
261
331
|
end
|
332
|
+
end
|
262
333
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
end
|
334
|
+
class ExampleRailsControllerMock
|
335
|
+
def action_name
|
336
|
+
"index"
|
267
337
|
end
|
268
338
|
|
269
|
-
|
270
|
-
|
339
|
+
def request
|
340
|
+
@request ||= ExampleRailsRequestMock.new
|
271
341
|
end
|
342
|
+
end
|
272
343
|
|
273
|
-
|
274
|
-
|
275
|
-
given_context = { :controller => ExampleRailsControllerMock.new }
|
276
|
-
with_rails_error_reporter do
|
277
|
-
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
278
|
-
end
|
344
|
+
class ExampleRailsJobMock
|
345
|
+
end
|
279
346
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
expect(transaction).to include_params("user_id" => 123, "password" => "[FILTERED]")
|
347
|
+
class ExampleRailsMailerMock < ActionMailer::MailDeliveryJob
|
348
|
+
def arguments
|
349
|
+
["ExampleRailsMailerMock", "send_mail"]
|
284
350
|
end
|
351
|
+
end
|
285
352
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
Rails.error.handle { raise ExampleStandardError }
|
290
|
-
end
|
353
|
+
before do
|
354
|
+
clear_current_transaction!
|
355
|
+
end
|
291
356
|
|
292
|
-
|
357
|
+
it "fetches the action, path and method from the controller in the context" do
|
358
|
+
# The controller key is set by Rails when raised in a controller
|
359
|
+
given_context = { :controller => ExampleRailsControllerMock.new }
|
360
|
+
with_rails_error_reporter do
|
361
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
293
362
|
end
|
363
|
+
|
364
|
+
transaction = last_transaction
|
365
|
+
expect(transaction).to have_action("ExampleRailsControllerMock#index")
|
366
|
+
expect(transaction).to include_metadata("path" => "path", "method" => "GET")
|
367
|
+
expect(transaction).to include_params("user_id" => 123,
|
368
|
+
"password" => "[FILTERED]")
|
294
369
|
end
|
295
370
|
|
296
|
-
it "sets
|
297
|
-
|
298
|
-
:controller => ExampleRailsControllerMock.new, # Not set as tag
|
299
|
-
:job => ExampleRailsJobMock.new, # Not set as tag
|
300
|
-
:appsignal => { :something => "not used" }, # Not set as tag
|
301
|
-
:tag1 => "value1",
|
302
|
-
:tag2 => "value2"
|
303
|
-
}
|
371
|
+
it "sets no action if no execution context is present" do
|
372
|
+
# The controller key is set by Rails when raised in a controller
|
304
373
|
with_rails_error_reporter do
|
305
|
-
Rails.error.handle
|
374
|
+
Rails.error.handle { raise ExampleStandardError }
|
306
375
|
end
|
307
376
|
|
308
|
-
expect(last_transaction).
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
377
|
+
expect(last_transaction).to_not have_action
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
it "sets the error context as tags" do
|
382
|
+
given_context = {
|
383
|
+
:controller => ExampleRailsControllerMock.new, # Not set as tag
|
384
|
+
:job => ExampleRailsJobMock.new, # Not set as tag
|
385
|
+
:appsignal => { :something => "not used" }, # Not set as tag
|
386
|
+
:tag1 => "value1",
|
387
|
+
:tag2 => "value2"
|
388
|
+
}
|
389
|
+
with_rails_error_reporter do
|
390
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
313
391
|
end
|
392
|
+
|
393
|
+
expect(last_transaction).to include_tags(
|
394
|
+
"tag1" => "value1",
|
395
|
+
"tag2" => "value2",
|
396
|
+
"severity" => "warning"
|
397
|
+
)
|
314
398
|
end
|
315
399
|
end
|
316
400
|
end
|
@@ -61,7 +61,7 @@ describe Appsignal::Integrations::ShoryukenMiddleware do
|
|
61
61
|
|
62
62
|
context "with parameter filtering" do
|
63
63
|
before do
|
64
|
-
|
64
|
+
start_agent("production")
|
65
65
|
Appsignal.config[:filter_parameters] = ["foo"]
|
66
66
|
end
|
67
67
|
|
@@ -243,7 +243,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
|
|
243
243
|
|
244
244
|
context "with parameter filtering" do
|
245
245
|
before do
|
246
|
-
|
246
|
+
start_agent("production")
|
247
247
|
Appsignal.config[:filter_parameters] = ["foo"]
|
248
248
|
end
|
249
249
|
|
@@ -384,7 +384,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
|
|
384
384
|
include RailsHelper
|
385
385
|
|
386
386
|
it "reports the worker name as the action, copies the namespace and tags" do
|
387
|
-
|
387
|
+
start_agent("production")
|
388
388
|
with_rails_error_reporter do
|
389
389
|
perform_sidekiq_job do
|
390
390
|
Appsignal.tag_job("test_tag" => "value")
|
@@ -527,6 +527,15 @@ if DependencyHelper.active_job_present?
|
|
527
527
|
end
|
528
528
|
end
|
529
529
|
around do |example|
|
530
|
+
with_rails_error_reporter do
|
531
|
+
keep_transactions do
|
532
|
+
Sidekiq::Testing.fake! do
|
533
|
+
example.run
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
537
|
+
end
|
538
|
+
before do
|
530
539
|
start_agent
|
531
540
|
Appsignal.internal_logger = test_logger(log)
|
532
541
|
ActiveJob::Base.queue_adapter = :sidekiq
|
@@ -551,13 +560,6 @@ if DependencyHelper.active_job_present?
|
|
551
560
|
Sidekiq::Testing.server_middleware do |chain|
|
552
561
|
chain.add Appsignal::Integrations::SidekiqMiddleware
|
553
562
|
end
|
554
|
-
with_rails_error_reporter do
|
555
|
-
keep_transactions do
|
556
|
-
Sidekiq::Testing.fake! do
|
557
|
-
example.run
|
558
|
-
end
|
559
|
-
end
|
560
|
-
end
|
561
563
|
end
|
562
564
|
after do
|
563
565
|
Object.send(:remove_const, :ActiveJobSidekiqTestJob)
|