appsignal 3.13.0 → 4.0.0.beta.1
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 +499 -487
- data/CHANGELOG.md +113 -0
- data/Rakefile +31 -7
- data/benchmark.rake +4 -6
- data/build_matrix.yml +45 -39
- data/ext/agent.rb +27 -27
- data/ext/appsignal_extension.c +25 -0
- data/gemfiles/rails-7.2.gemfile +11 -0
- data/lib/appsignal/check_in/cron.rb +2 -15
- data/lib/appsignal/cli/diagnose.rb +37 -28
- data/lib/appsignal/cli/install.rb +5 -1
- data/lib/appsignal/config.rb +57 -119
- data/lib/appsignal/demo.rb +2 -2
- data/lib/appsignal/extension/jruby.rb +14 -0
- data/lib/appsignal/helpers/instrumentation.rb +139 -417
- data/lib/appsignal/helpers/metrics.rb +0 -16
- data/lib/appsignal/hooks/action_cable.rb +8 -8
- data/lib/appsignal/hooks/active_job.rb +2 -2
- data/lib/appsignal/hooks/at_exit.rb +37 -0
- data/lib/appsignal/hooks.rb +1 -16
- data/lib/appsignal/integrations/action_cable.rb +2 -2
- data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
- data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
- data/lib/appsignal/integrations/que.rb +2 -2
- data/lib/appsignal/integrations/railtie.rb +26 -59
- data/lib/appsignal/integrations/rake.rb +2 -2
- data/lib/appsignal/integrations/resque.rb +2 -2
- data/lib/appsignal/integrations/shoryuken.rb +4 -4
- data/lib/appsignal/integrations/sidekiq.rb +3 -3
- data/lib/appsignal/integrations/webmachine.rb +2 -2
- data/lib/appsignal/loaders.rb +1 -1
- data/lib/appsignal/probes.rb +0 -9
- data/lib/appsignal/rack/abstract_middleware.rb +4 -26
- data/lib/appsignal/rack/event_handler.rb +4 -4
- data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
- data/lib/appsignal/rack.rb +0 -25
- data/lib/appsignal/sample_data.rb +95 -0
- data/lib/appsignal/transaction.rb +235 -361
- data/lib/appsignal/utils/rails_helper.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +19 -71
- data/spec/lib/appsignal/auth_check_spec.rb +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
- data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
- data/spec/lib/appsignal/check_in_spec.rb +1 -207
- data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
- data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
- data/spec/lib/appsignal/config_spec.rb +304 -379
- data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
- data/spec/lib/appsignal/extension_spec.rb +5 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
- data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
- data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
- data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
- data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
- data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
- data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
- data/spec/lib/appsignal/hooks_spec.rb +0 -41
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
- data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
- data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
- data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
- data/spec/lib/appsignal/loaders_spec.rb +8 -1
- data/spec/lib/appsignal/marker_spec.rb +1 -1
- data/spec/lib/appsignal/probes_spec.rb +4 -83
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
- data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
- data/spec/lib/appsignal/sample_data_spec.rb +174 -0
- data/spec/lib/appsignal/transaction_spec.rb +791 -1031
- data/spec/lib/appsignal/transmitter_spec.rb +6 -8
- data/spec/lib/appsignal_spec.rb +294 -643
- data/spec/spec_helper.rb +1 -3
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
- data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
- data/spec/support/helpers/api_request_helper.rb +3 -2
- data/spec/support/helpers/config_helpers.rb +41 -11
- data/spec/support/helpers/dependency_helper.rb +8 -0
- data/spec/support/helpers/log_helpers.rb +1 -0
- data/spec/support/helpers/rails_helper.rb +6 -6
- data/spec/support/helpers/transaction_helpers.rb +2 -24
- data/spec/support/matchers/transaction.rb +3 -3
- data/spec/support/mocks/appsignal_mock.rb +3 -3
- data/spec/support/mocks/mock_probe.rb +2 -0
- data/spec/support/testing.rb +2 -2
- metadata +12 -22
- data/gemfiles/que_beta.gemfile +0 -5
- data/lib/appsignal/helpers/heartbeat.rb +0 -20
- data/lib/appsignal/integrations/grape.rb +0 -35
- data/lib/appsignal/integrations/hanami.rb +0 -13
- data/lib/appsignal/integrations/padrino.rb +0 -13
- data/lib/appsignal/integrations/sinatra.rb +0 -13
- data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
- data/lib/appsignal/rack/streaming_listener.rb +0 -28
- data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
- data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
- data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
- data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
- data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
- data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
- data/spec/support/rails/my_app.rb +0 -6
- /data/spec/support/fixtures/projects/{valid/config/application.rb → valid_with_rails_app/log/.gitkeep} +0 -0
@@ -3,19 +3,9 @@ if DependencyHelper.rails_present?
|
|
3
3
|
|
4
4
|
describe Appsignal::Integrations::Railtie do
|
5
5
|
include RailsHelper
|
6
|
-
|
6
|
+
before { Appsignal.clear! }
|
7
7
|
after { clear_rails_error_reporter! }
|
8
8
|
|
9
|
-
module RailtieHelper
|
10
|
-
def self.ensure_initialize!
|
11
|
-
return if @initialized
|
12
|
-
|
13
|
-
MyApp::Application.config.root = ConfigHelpers.project_fixture_path
|
14
|
-
MyApp::Application.initialize!
|
15
|
-
@initialized = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
9
|
def expect_middleware_to_match(middleware, klass, args)
|
20
10
|
expect(middleware.klass).to eq(klass)
|
21
11
|
expect(middleware.args).to match(args)
|
@@ -26,23 +16,32 @@ if DependencyHelper.rails_present?
|
|
26
16
|
expect(Appsignal::Integrations::Railtie).to receive(:on_load).and_call_original
|
27
17
|
expect(Appsignal::Integrations::Railtie).to receive(:after_initialize).and_call_original
|
28
18
|
|
29
|
-
|
19
|
+
if MyApp::Application.initialized?
|
20
|
+
run_appsignal_railtie
|
21
|
+
else
|
22
|
+
MyApp::Application.initialize!
|
23
|
+
end
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
33
27
|
describe "initializer" do
|
34
28
|
let(:app) { MyApp::Application.new }
|
35
29
|
before do
|
36
|
-
|
37
|
-
|
30
|
+
# Make sure it's initialized at least once
|
31
|
+
MyApp::Application.initialize!
|
32
|
+
Appsignal.clear!
|
38
33
|
end
|
39
34
|
|
40
35
|
def initialize_railtie(event)
|
41
|
-
MyApp::Application.config.root =
|
36
|
+
MyApp::Application.config.root = rails_project_fixture_path
|
42
37
|
case event
|
43
38
|
when :on_load
|
44
39
|
described_class.on_load(app)
|
45
40
|
when :after_initialize
|
41
|
+
# Must call both so no steps are missed
|
42
|
+
described_class.on_load(app)
|
43
|
+
described_class.after_initialize(app)
|
44
|
+
when :only_after_initialize
|
46
45
|
described_class.after_initialize(app)
|
47
46
|
else
|
48
47
|
raise "Unsupported test event '#{event}'"
|
@@ -56,19 +55,6 @@ if DependencyHelper.rails_present?
|
|
56
55
|
expect(Appsignal.active?).to be_truthy
|
57
56
|
end
|
58
57
|
|
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)
|
66
|
-
|
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
|
71
|
-
|
72
58
|
it "sets the detected environment" do
|
73
59
|
initialize_railtie(event)
|
74
60
|
|
@@ -85,13 +71,17 @@ if DependencyHelper.rails_present?
|
|
85
71
|
it "sets the Rails app path as root_path" do
|
86
72
|
initialize_railtie(event)
|
87
73
|
|
88
|
-
expect(Appsignal.config.root_path).to eq(Pathname.new(
|
74
|
+
expect(Appsignal.config.root_path).to eq(Pathname.new(rails_project_fixture_path))
|
89
75
|
end
|
90
76
|
|
91
77
|
it "loads the Rails app name in the initial config" do
|
92
78
|
initialize_railtie(event)
|
93
79
|
|
94
|
-
|
80
|
+
rails_defaults = Appsignal::Config.loader_defaults
|
81
|
+
.find { |loader| loader[:name] == :rails }
|
82
|
+
expect(rails_defaults[:options][:name]).to eq("MyApp")
|
83
|
+
expect(rails_defaults[:options][:log_path])
|
84
|
+
.to eq(Pathname.new(File.join(rails_project_fixture_path, "log")))
|
95
85
|
end
|
96
86
|
|
97
87
|
it "loads the app name from the project's appsignal.yml file" do
|
@@ -104,7 +94,7 @@ if DependencyHelper.rails_present?
|
|
104
94
|
initialize_railtie(event)
|
105
95
|
|
106
96
|
expect(Appsignal.config[:log_path])
|
107
|
-
.to eq(Pathname.new(File.join(
|
97
|
+
.to eq(Pathname.new(File.join(rails_project_fixture_path, "log")))
|
108
98
|
end
|
109
99
|
|
110
100
|
it "adds the middleware" do
|
@@ -182,7 +172,7 @@ if DependencyHelper.rails_present?
|
|
182
172
|
app.config.appsignal.start_at = :after_initialize
|
183
173
|
initialize_railtie(event)
|
184
174
|
|
185
|
-
expect(Appsignal.
|
175
|
+
expect(Appsignal.started?).to be_falsy
|
186
176
|
expect(Appsignal.config).to be_nil
|
187
177
|
end
|
188
178
|
end
|
@@ -200,11 +190,16 @@ if DependencyHelper.rails_present?
|
|
200
190
|
end
|
201
191
|
|
202
192
|
context "when start_at == :on_load" do
|
193
|
+
before do
|
194
|
+
Appsignal.clear_started!
|
195
|
+
Appsignal.clear_config!
|
196
|
+
end
|
197
|
+
|
203
198
|
it "does not start AppSignal" do
|
204
199
|
app.config.appsignal.start_at = :on_load
|
205
|
-
initialize_railtie(
|
200
|
+
initialize_railtie(:only_after_initialize)
|
206
201
|
|
207
|
-
expect(Appsignal.
|
202
|
+
expect(Appsignal.started?).to be_falsy
|
208
203
|
expect(Appsignal.config).to be_nil
|
209
204
|
end
|
210
205
|
end
|
@@ -216,36 +211,84 @@ if DependencyHelper.rails_present?
|
|
216
211
|
before { start_agent }
|
217
212
|
around { |example| keep_transactions { example.run } }
|
218
213
|
|
219
|
-
|
220
|
-
|
214
|
+
it "reports the error when the error is not handled (reraises the error)" do
|
215
|
+
with_rails_error_reporter do
|
216
|
+
expect do
|
217
|
+
Rails.error.record { raise ExampleStandardError, "error message" }
|
218
|
+
end.to raise_error(ExampleStandardError, "error message")
|
219
|
+
end
|
220
|
+
|
221
|
+
expect(last_transaction).to have_error("ExampleStandardError", "error message")
|
222
|
+
end
|
223
|
+
|
224
|
+
it "reports the error when the error is handled (not reraised)" do
|
225
|
+
with_rails_error_reporter do
|
226
|
+
Rails.error.handle { raise ExampleStandardError, "error message" }
|
227
|
+
end
|
228
|
+
|
229
|
+
expect(last_transaction).to have_error("ExampleStandardError", "error message")
|
230
|
+
end
|
231
|
+
|
232
|
+
context "when no transaction is active" do
|
233
|
+
it "reports the error on a new transaction" do
|
221
234
|
with_rails_error_reporter do
|
222
235
|
expect do
|
223
|
-
Rails.error.
|
224
|
-
end.to
|
225
|
-
end
|
236
|
+
Rails.error.handle { raise ExampleStandardError, "error message" }
|
237
|
+
end.to change { created_transactions.count }.by(1)
|
226
238
|
|
227
|
-
|
239
|
+
transaction = last_transaction
|
240
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
241
|
+
expect(transaction).to_not have_action
|
242
|
+
expect(transaction).to have_error("ExampleStandardError", "error message")
|
243
|
+
end
|
228
244
|
end
|
229
245
|
end
|
230
246
|
|
231
|
-
context "when
|
232
|
-
|
233
|
-
|
247
|
+
context "when a transaction is active" do
|
248
|
+
it "reports the error on the transaction when a transaction is active" do
|
249
|
+
current_transaction = http_request_transaction
|
250
|
+
current_transaction.set_namespace "custom"
|
251
|
+
current_transaction.set_action "CustomAction"
|
252
|
+
current_transaction.add_tags(:duplicated_tag => "duplicated value")
|
253
|
+
|
254
|
+
with_rails_error_reporter do
|
255
|
+
with_current_transaction current_transaction do
|
256
|
+
Rails.error.handle { raise ExampleStandardError, "error message" }
|
257
|
+
expect do
|
258
|
+
current_transaction.complete
|
259
|
+
end.to_not(change { created_transactions.count })
|
260
|
+
|
261
|
+
transaction = current_transaction
|
262
|
+
expect(transaction).to have_namespace("custom")
|
263
|
+
expect(transaction).to have_action("CustomAction")
|
264
|
+
expect(transaction).to have_error("ExampleStandardError", "error message")
|
265
|
+
expect(transaction).to include_tags(
|
266
|
+
"duplicated_tag" => "duplicated value",
|
267
|
+
"severity" => "warning"
|
268
|
+
)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
context "when the current transaction has an error" do
|
274
|
+
it "reports the error on a new transaction" do
|
234
275
|
current_transaction = http_request_transaction
|
235
276
|
current_transaction.set_namespace "custom"
|
236
277
|
current_transaction.set_action "CustomAction"
|
237
|
-
current_transaction.
|
238
|
-
|
239
|
-
)
|
278
|
+
current_transaction.add_tags(:duplicated_tag => "duplicated value")
|
279
|
+
current_transaction.add_error(ExampleStandardError.new("error message"))
|
240
280
|
|
241
281
|
with_rails_error_reporter do
|
242
282
|
with_current_transaction current_transaction do
|
243
|
-
Rails.error.handle { raise ExampleStandardError, "
|
283
|
+
Rails.error.handle { raise ExampleStandardError, "other message" }
|
284
|
+
expect do
|
285
|
+
current_transaction.complete
|
286
|
+
end.to change { created_transactions.count }.by(1)
|
244
287
|
|
245
288
|
transaction = last_transaction
|
246
289
|
expect(transaction).to have_namespace("custom")
|
247
290
|
expect(transaction).to have_action("CustomAction")
|
248
|
-
expect(transaction).to have_error("ExampleStandardError", "
|
291
|
+
expect(transaction).to have_error("ExampleStandardError", "other message")
|
249
292
|
expect(transaction).to include_tags(
|
250
293
|
"duplicated_tag" => "duplicated value",
|
251
294
|
"severity" => "warning"
|
@@ -254,148 +297,127 @@ if DependencyHelper.rails_present?
|
|
254
297
|
end
|
255
298
|
end
|
256
299
|
|
257
|
-
it "
|
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
|
-
)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
it "sends tags stored in :appsignal -> :custom_data as custom data" do
|
276
|
-
current_transaction = http_request_transaction
|
277
|
-
|
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
|
-
}
|
286
|
-
}
|
287
|
-
}
|
288
|
-
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
289
|
-
|
290
|
-
transaction = last_transaction
|
291
|
-
expect(transaction).to include_custom_data(
|
292
|
-
"array" => [1, 2],
|
293
|
-
"hash" => { "one" => 1, "two" => 2 }
|
294
|
-
)
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
it "overwrites duplicated namespace and action with custom from context" do
|
300
|
+
it "reports the error on a new transaction with the given context" do
|
300
301
|
current_transaction = http_request_transaction
|
301
302
|
current_transaction.set_namespace "custom"
|
302
303
|
current_transaction.set_action "CustomAction"
|
304
|
+
current_transaction.add_tags(:duplicated_tag => "duplicated value")
|
305
|
+
current_transaction.add_custom_data(:original => "custom value")
|
306
|
+
current_transaction.add_error(ExampleStandardError.new("error message"))
|
303
307
|
|
304
308
|
with_rails_error_reporter do
|
305
309
|
with_current_transaction current_transaction do
|
306
310
|
given_context = {
|
307
|
-
:appsignal => {
|
311
|
+
:appsignal => {
|
312
|
+
:namespace => "context",
|
313
|
+
:action => "ContextAction",
|
314
|
+
:custom_data => { :context => "context data" }
|
315
|
+
|
316
|
+
}
|
308
317
|
}
|
309
|
-
Rails.error.handle(:context => given_context)
|
318
|
+
Rails.error.handle(:context => given_context) do
|
319
|
+
raise ExampleStandardError, "other message"
|
320
|
+
end
|
321
|
+
expect do
|
322
|
+
current_transaction.complete
|
323
|
+
end.to change { created_transactions.count }.by(1)
|
310
324
|
|
311
325
|
transaction = last_transaction
|
312
326
|
expect(transaction).to have_namespace("context")
|
313
327
|
expect(transaction).to have_action("ContextAction")
|
328
|
+
expect(transaction).to have_error("ExampleStandardError", "other message")
|
329
|
+
expect(transaction).to include_tags(
|
330
|
+
"duplicated_tag" => "duplicated value",
|
331
|
+
"severity" => "warning"
|
332
|
+
)
|
333
|
+
expect(transaction).to include_custom_data(
|
334
|
+
"original" => "custom value",
|
335
|
+
"context" => "context data"
|
336
|
+
)
|
314
337
|
end
|
315
338
|
end
|
316
339
|
end
|
317
340
|
end
|
318
341
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
"path"
|
323
|
-
end
|
324
|
-
|
325
|
-
def method
|
326
|
-
"GET"
|
327
|
-
end
|
328
|
-
|
329
|
-
def filtered_parameters
|
330
|
-
{ :user_id => 123, :password => "[FILTERED]" }
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
class ExampleRailsControllerMock
|
335
|
-
def action_name
|
336
|
-
"index"
|
337
|
-
end
|
342
|
+
it "overwrites duplicate tags with tags from context" do
|
343
|
+
current_transaction = http_request_transaction
|
344
|
+
current_transaction.add_tags(:tag1 => "duplicated value")
|
338
345
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
class ExampleRailsJobMock
|
345
|
-
end
|
346
|
+
with_rails_error_reporter do
|
347
|
+
with_current_transaction current_transaction do
|
348
|
+
given_context = { :tag1 => "value1", :tag2 => "value2" }
|
349
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
350
|
+
current_transaction.complete
|
346
351
|
|
347
|
-
|
348
|
-
|
349
|
-
|
352
|
+
expect(current_transaction).to include_tags(
|
353
|
+
"tag1" => "value1",
|
354
|
+
"tag2" => "value2",
|
355
|
+
"severity" => "warning"
|
356
|
+
)
|
350
357
|
end
|
351
358
|
end
|
359
|
+
end
|
352
360
|
|
353
|
-
|
354
|
-
|
355
|
-
|
361
|
+
it "sets namespace, action and custom data with values from context" do
|
362
|
+
current_transaction = http_request_transaction
|
363
|
+
current_transaction.set_namespace "custom"
|
364
|
+
current_transaction.set_action "CustomAction"
|
356
365
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
366
|
+
with_rails_error_reporter do
|
367
|
+
with_current_transaction current_transaction do
|
368
|
+
given_context = {
|
369
|
+
:appsignal => {
|
370
|
+
:namespace => "context",
|
371
|
+
:action => "ContextAction",
|
372
|
+
:custom_data => { :data => "context data" }
|
373
|
+
}
|
374
|
+
}
|
361
375
|
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
362
|
-
|
376
|
+
current_transaction.complete
|
363
377
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
"password" => "[FILTERED]")
|
378
|
+
expect(current_transaction).to have_namespace("context")
|
379
|
+
expect(current_transaction).to have_action("ContextAction")
|
380
|
+
expect(current_transaction).to include_custom_data("data" => "context data")
|
381
|
+
end
|
369
382
|
end
|
383
|
+
end
|
384
|
+
end
|
370
385
|
|
371
|
-
|
372
|
-
|
386
|
+
if DependencyHelper.rails7_1_present?
|
387
|
+
it "sets the namespace to 'runner' if the source is the Rails runner" do
|
388
|
+
expect do
|
373
389
|
with_rails_error_reporter do
|
374
|
-
|
390
|
+
expect do
|
391
|
+
Rails.error.record(:source => "application.runner.railties") do
|
392
|
+
raise ExampleStandardError, "error message"
|
393
|
+
end
|
394
|
+
end.to raise_error(ExampleStandardError, "error message")
|
375
395
|
end
|
396
|
+
end.to change { created_transactions.count }.by(1)
|
376
397
|
|
377
|
-
|
378
|
-
|
398
|
+
transaction = last_transaction
|
399
|
+
expect(transaction).to have_namespace("runner")
|
400
|
+
expect(transaction).to_not have_action
|
401
|
+
expect(transaction).to have_error("ExampleStandardError", "error message")
|
402
|
+
expect(transaction).to include_tags("source" => "application.runner.railties")
|
379
403
|
end
|
404
|
+
end
|
380
405
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
}
|
389
|
-
with_rails_error_reporter do
|
390
|
-
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
391
|
-
end
|
392
|
-
|
393
|
-
expect(last_transaction).to include_tags(
|
394
|
-
"tag1" => "value1",
|
395
|
-
"tag2" => "value2",
|
396
|
-
"severity" => "warning"
|
397
|
-
)
|
406
|
+
it "sets the error context as tags" do
|
407
|
+
given_context = {
|
408
|
+
:appsignal => { :something => "not used" }, # Not set as tag
|
409
|
+
:tag1 => "value1",
|
410
|
+
:tag2 => "value2"
|
411
|
+
}
|
412
|
+
with_rails_error_reporter do
|
413
|
+
Rails.error.handle(:context => given_context) { raise ExampleStandardError }
|
398
414
|
end
|
415
|
+
|
416
|
+
expect(last_transaction).to include_tags(
|
417
|
+
"tag1" => "value1",
|
418
|
+
"tag2" => "value2",
|
419
|
+
"severity" => "warning"
|
420
|
+
)
|
399
421
|
end
|
400
422
|
end
|
401
423
|
end
|
@@ -9,7 +9,8 @@ describe Appsignal::Integrations::ShoryukenMiddleware do
|
|
9
9
|
let(:queue) { "some-funky-queue-name" }
|
10
10
|
let(:sqs_msg) { double(:message_id => "msg1", :attributes => {}) }
|
11
11
|
let(:body) { {} }
|
12
|
-
|
12
|
+
let(:options) { {} }
|
13
|
+
before { start_agent(:options => options) }
|
13
14
|
around { |example| keep_transactions { example.run } }
|
14
15
|
|
15
16
|
def perform_shoryuken_job(&block)
|
@@ -60,10 +61,7 @@ describe Appsignal::Integrations::ShoryukenMiddleware do
|
|
60
61
|
end
|
61
62
|
|
62
63
|
context "with parameter filtering" do
|
63
|
-
|
64
|
-
start_agent("production")
|
65
|
-
Appsignal.config[:filter_parameters] = ["foo"]
|
66
|
-
end
|
64
|
+
let(:options) { { :filter_parameters => ["foo"] } }
|
67
65
|
|
68
66
|
it "filters selected arguments" do
|
69
67
|
perform_shoryuken_job
|