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
@@ -40,10 +40,8 @@ describe Appsignal::Transaction do
|
|
40
40
|
expect(transaction.namespace).to eq namespace
|
41
41
|
expect(transaction.request).to eq request
|
42
42
|
|
43
|
-
expect(transaction
|
44
|
-
|
45
|
-
"namespace" => namespace
|
46
|
-
)
|
43
|
+
expect(transaction).to have_id(transaction_id)
|
44
|
+
expect(transaction).to have_namespace(namespace)
|
47
45
|
end
|
48
46
|
|
49
47
|
it "assigns the transaction to current" do
|
@@ -85,10 +83,6 @@ describe Appsignal::Transaction do
|
|
85
83
|
end
|
86
84
|
|
87
85
|
describe ".current" do
|
88
|
-
def current_transaction
|
89
|
-
Appsignal::Transaction.current
|
90
|
-
end
|
91
|
-
|
92
86
|
context "when there is a current transaction" do
|
93
87
|
let!(:transaction) do
|
94
88
|
Appsignal::Transaction.create(transaction_id, namespace, request, options)
|
@@ -166,9 +160,7 @@ describe Appsignal::Transaction do
|
|
166
160
|
it "samples data" do
|
167
161
|
transaction.set_tags(:foo => "bar")
|
168
162
|
keep_transactions { transaction.complete }
|
169
|
-
expect(transaction
|
170
|
-
"tags" => { "foo" => "bar" }
|
171
|
-
)
|
163
|
+
expect(transaction).to include_tags("foo" => "bar")
|
172
164
|
end
|
173
165
|
end
|
174
166
|
|
@@ -181,13 +173,13 @@ describe Appsignal::Transaction do
|
|
181
173
|
|
182
174
|
context "when a transaction is marked as discarded" do
|
183
175
|
it "does not complete the transaction" do
|
184
|
-
expect(transaction.ext).to_not receive(:complete)
|
185
|
-
|
186
176
|
expect do
|
187
177
|
transaction.discard!
|
188
178
|
end.to change { transaction.discarded? }.from(false).to(true)
|
189
179
|
|
190
180
|
transaction.complete
|
181
|
+
|
182
|
+
expect(transaction).to_not be_completed
|
191
183
|
end
|
192
184
|
|
193
185
|
it "logs a debug message" do
|
@@ -202,13 +194,13 @@ describe Appsignal::Transaction do
|
|
202
194
|
before { transaction.discard! }
|
203
195
|
|
204
196
|
it "completes the transaction" do
|
205
|
-
expect(transaction.ext).to receive(:complete).and_call_original
|
206
|
-
|
207
197
|
expect do
|
208
198
|
transaction.restore!
|
209
199
|
end.to change { transaction.discarded? }.from(true).to(false)
|
210
200
|
|
211
201
|
transaction.complete
|
202
|
+
|
203
|
+
expect(transaction).to be_completed
|
212
204
|
end
|
213
205
|
end
|
214
206
|
end
|
@@ -334,6 +326,16 @@ describe Appsignal::Transaction do
|
|
334
326
|
it "returns custom parameters" do
|
335
327
|
expect(subject).to eq(:foo => "bar")
|
336
328
|
end
|
329
|
+
|
330
|
+
context "when params is a callable object" do
|
331
|
+
it "calls the params object and sets the return value as parametesr" do
|
332
|
+
transaction.set_params { { "param1" => "value1" } }
|
333
|
+
|
334
|
+
expect(transaction.params).to eq(
|
335
|
+
"param1" => "value1"
|
336
|
+
)
|
337
|
+
end
|
338
|
+
end
|
337
339
|
end
|
338
340
|
|
339
341
|
context "without custom params set on transaction" do
|
@@ -354,9 +356,9 @@ describe Appsignal::Transaction do
|
|
354
356
|
params = { "foo" => "bar" }
|
355
357
|
silence { transaction.params = params }
|
356
358
|
|
357
|
-
transaction.
|
359
|
+
transaction._sample
|
358
360
|
expect(transaction.params).to eq(params)
|
359
|
-
expect(transaction
|
361
|
+
expect(transaction).to include_params(params)
|
360
362
|
end
|
361
363
|
|
362
364
|
it "logs a deprecation warning" do
|
@@ -378,9 +380,28 @@ describe Appsignal::Transaction do
|
|
378
380
|
params = { "key" => "value" }
|
379
381
|
transaction.set_params(params)
|
380
382
|
|
381
|
-
transaction.
|
383
|
+
transaction._sample
|
382
384
|
expect(transaction.params).to eq(params)
|
383
|
-
expect(transaction
|
385
|
+
expect(transaction).to include_params(params)
|
386
|
+
end
|
387
|
+
|
388
|
+
it "updates the params on the transaction with a block" do
|
389
|
+
params = { "key" => "value" }
|
390
|
+
transaction.set_params { params }
|
391
|
+
|
392
|
+
transaction._sample
|
393
|
+
expect(transaction.params).to eq(params)
|
394
|
+
expect(transaction).to include_params(params)
|
395
|
+
end
|
396
|
+
|
397
|
+
it "updates with the params argument when both an argument and block are given" do
|
398
|
+
arg_params = { "argument" => "value" }
|
399
|
+
block_params = { "block" => "value" }
|
400
|
+
transaction.set_params(arg_params) { block_params }
|
401
|
+
|
402
|
+
transaction._sample
|
403
|
+
expect(transaction.params).to eq(arg_params)
|
404
|
+
expect(transaction).to include_params(arg_params)
|
384
405
|
end
|
385
406
|
end
|
386
407
|
|
@@ -390,9 +411,9 @@ describe Appsignal::Transaction do
|
|
390
411
|
transaction.set_params(params)
|
391
412
|
transaction.set_params(nil)
|
392
413
|
|
393
|
-
transaction.
|
414
|
+
transaction._sample
|
394
415
|
expect(transaction.params).to eq(params)
|
395
|
-
expect(transaction
|
416
|
+
expect(transaction).to include_params(params)
|
396
417
|
end
|
397
418
|
end
|
398
419
|
end
|
@@ -405,9 +426,28 @@ describe Appsignal::Transaction do
|
|
405
426
|
params = { "key" => "value" }
|
406
427
|
transaction.set_params_if_nil(params)
|
407
428
|
|
408
|
-
transaction.
|
429
|
+
transaction._sample
|
409
430
|
expect(transaction.params).to eq(params)
|
410
|
-
expect(transaction
|
431
|
+
expect(transaction).to include_params(params)
|
432
|
+
end
|
433
|
+
|
434
|
+
it "updates the params on the transaction with a block" do
|
435
|
+
params = { "key" => "value" }
|
436
|
+
transaction.set_params_if_nil { params }
|
437
|
+
|
438
|
+
transaction._sample
|
439
|
+
expect(transaction.params).to eq(params)
|
440
|
+
expect(transaction).to include_params(params)
|
441
|
+
end
|
442
|
+
|
443
|
+
it "updates with the params argument when both an argument and block are given" do
|
444
|
+
arg_params = { "argument" => "value" }
|
445
|
+
block_params = { "block" => "value" }
|
446
|
+
transaction.set_params_if_nil(arg_params) { block_params }
|
447
|
+
|
448
|
+
transaction._sample
|
449
|
+
expect(transaction.params).to eq(arg_params)
|
450
|
+
expect(transaction).to include_params(arg_params)
|
411
451
|
end
|
412
452
|
|
413
453
|
context "when the given params is nil" do
|
@@ -416,9 +456,9 @@ describe Appsignal::Transaction do
|
|
416
456
|
transaction.set_params(params)
|
417
457
|
transaction.set_params_if_nil(nil)
|
418
458
|
|
419
|
-
transaction.
|
459
|
+
transaction._sample
|
420
460
|
expect(transaction.params).to eq(params)
|
421
|
-
expect(transaction
|
461
|
+
expect(transaction).to include_params(params)
|
422
462
|
end
|
423
463
|
end
|
424
464
|
end
|
@@ -430,16 +470,28 @@ describe Appsignal::Transaction do
|
|
430
470
|
transaction.set_params(preset_params)
|
431
471
|
transaction.set_params_if_nil(params)
|
432
472
|
|
433
|
-
transaction.
|
473
|
+
transaction._sample
|
434
474
|
expect(transaction.params).to eq(preset_params)
|
435
|
-
expect(transaction
|
475
|
+
expect(transaction).to include_params(preset_params)
|
476
|
+
end
|
477
|
+
|
478
|
+
it "does not update the params with a block on the transaction" do
|
479
|
+
preset_params = { "other" => "params" }
|
480
|
+
params = { "key" => "value" }
|
481
|
+
transaction.set_params(preset_params)
|
482
|
+
transaction.set_params_if_nil { params }
|
483
|
+
|
484
|
+
transaction._sample
|
485
|
+
expect(transaction.params).to eq(preset_params)
|
486
|
+
expect(transaction).to include_params(preset_params)
|
436
487
|
end
|
437
488
|
end
|
438
489
|
end
|
439
490
|
|
440
491
|
describe "#set_tags" do
|
441
492
|
let(:long_string) { "a" * 10_001 }
|
442
|
-
|
493
|
+
|
494
|
+
it "stores tags on the transaction" do
|
443
495
|
transaction.set_tags(
|
444
496
|
:valid_key => "valid_value",
|
445
497
|
"valid_string_key" => "valid_value",
|
@@ -451,11 +503,9 @@ describe Appsignal::Transaction do
|
|
451
503
|
:too_long_value => long_string,
|
452
504
|
long_string => "too_long_key"
|
453
505
|
)
|
454
|
-
transaction.
|
455
|
-
end
|
506
|
+
transaction._sample
|
456
507
|
|
457
|
-
|
458
|
-
expect(transaction.to_h["sample_data"]["tags"]).to eq(
|
508
|
+
expect(transaction).to include_tags(
|
459
509
|
"valid_key" => "valid_value",
|
460
510
|
"valid_string_key" => "valid_value",
|
461
511
|
"both_symbols" => "valid_value",
|
@@ -464,6 +514,96 @@ describe Appsignal::Transaction do
|
|
464
514
|
long_string => "too_long_key"
|
465
515
|
)
|
466
516
|
end
|
517
|
+
|
518
|
+
it "merges the tags when called multiple times" do
|
519
|
+
transaction.set_tags(:key1 => "value1")
|
520
|
+
transaction.set_tags(:key2 => "value2")
|
521
|
+
transaction._sample
|
522
|
+
|
523
|
+
expect(transaction).to include_tags(
|
524
|
+
"key1" => "value1",
|
525
|
+
"key2" => "value2"
|
526
|
+
)
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
describe "#set_custom_data" do
|
531
|
+
let(:log_stream) { std_stream }
|
532
|
+
let(:logs) { log_contents(log_stream) }
|
533
|
+
around { |example| use_logger_with(log_stream) { example.run } }
|
534
|
+
|
535
|
+
it "stores custom Hash data on the transaction" do
|
536
|
+
transaction.set_custom_data(
|
537
|
+
:user => {
|
538
|
+
:id => 123,
|
539
|
+
:locale => "abc"
|
540
|
+
},
|
541
|
+
:organization => {
|
542
|
+
:slug => "appsignal",
|
543
|
+
:plan => "enterprise"
|
544
|
+
}
|
545
|
+
)
|
546
|
+
|
547
|
+
transaction._sample
|
548
|
+
expect(transaction).to include_custom_data(
|
549
|
+
"user" => {
|
550
|
+
"id" => 123,
|
551
|
+
"locale" => "abc"
|
552
|
+
},
|
553
|
+
"organization" => {
|
554
|
+
"slug" => "appsignal",
|
555
|
+
"plan" => "enterprise"
|
556
|
+
}
|
557
|
+
)
|
558
|
+
end
|
559
|
+
|
560
|
+
it "stores custom Array data on the transaction" do
|
561
|
+
transaction.set_custom_data([
|
562
|
+
[123, "abc"],
|
563
|
+
["appsignal", "enterprise"]
|
564
|
+
])
|
565
|
+
|
566
|
+
transaction._sample
|
567
|
+
expect(transaction).to include_custom_data([
|
568
|
+
[123, "abc"],
|
569
|
+
["appsignal", "enterprise"]
|
570
|
+
])
|
571
|
+
end
|
572
|
+
|
573
|
+
it "does not store non Hash or Array custom data" do
|
574
|
+
transaction.set_custom_data("abc")
|
575
|
+
transaction._sample
|
576
|
+
expect(transaction).to_not include_custom_data
|
577
|
+
|
578
|
+
transaction.set_custom_data(123)
|
579
|
+
transaction._sample
|
580
|
+
expect(transaction).to_not include_custom_data
|
581
|
+
|
582
|
+
transaction.set_custom_data(Object.new)
|
583
|
+
transaction._sample
|
584
|
+
expect(transaction).to_not include_custom_data
|
585
|
+
|
586
|
+
expect(logs).to contains_log(
|
587
|
+
:error,
|
588
|
+
"set_custom_data: Unsupported data type String received."
|
589
|
+
)
|
590
|
+
expect(logs).to contains_log(
|
591
|
+
:error,
|
592
|
+
"set_custom_data: Unsupported data type Integer received."
|
593
|
+
)
|
594
|
+
expect(logs).to contains_log(
|
595
|
+
:error,
|
596
|
+
"set_custom_data: Unsupported data type String received."
|
597
|
+
)
|
598
|
+
end
|
599
|
+
|
600
|
+
it "overwrites the custom data if called multiple times" do
|
601
|
+
transaction.set_custom_data("user" => { "id" => 123 })
|
602
|
+
transaction.set_custom_data("user" => { "id" => 456 })
|
603
|
+
|
604
|
+
transaction._sample
|
605
|
+
expect(transaction).to include_custom_data("user" => { "id" => 456 })
|
606
|
+
end
|
467
607
|
end
|
468
608
|
|
469
609
|
describe "#add_breadcrumb" do
|
@@ -507,12 +647,13 @@ describe Appsignal::Transaction do
|
|
507
647
|
transaction.sample_data
|
508
648
|
timeframe_end = Time.now.utc.to_i
|
509
649
|
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
650
|
+
expect(transaction).to include_breadcrumb(
|
651
|
+
"clicked HOME",
|
652
|
+
"user_action",
|
653
|
+
"",
|
654
|
+
{},
|
655
|
+
be_between(timeframe_start, timeframe_end)
|
656
|
+
)
|
516
657
|
end
|
517
658
|
end
|
518
659
|
|
@@ -521,7 +662,7 @@ describe Appsignal::Transaction do
|
|
521
662
|
transaction.add_breadcrumb("category", "action", "message", "invalid metadata")
|
522
663
|
transaction.sample_data
|
523
664
|
|
524
|
-
expect(transaction
|
665
|
+
expect(transaction).to_not include_breadcrumbs
|
525
666
|
expect(log_contents(log)).to contains_log(
|
526
667
|
:error,
|
527
668
|
"add_breadcrumb: Cannot add breadcrumb. The given metadata argument is not a Hash."
|
@@ -537,7 +678,7 @@ describe Appsignal::Transaction do
|
|
537
678
|
transaction.set_action(action_name)
|
538
679
|
|
539
680
|
expect(transaction.action).to eq(action_name)
|
540
|
-
expect(transaction
|
681
|
+
expect(transaction).to have_action(action_name)
|
541
682
|
end
|
542
683
|
end
|
543
684
|
|
@@ -548,7 +689,7 @@ describe Appsignal::Transaction do
|
|
548
689
|
transaction.set_action(nil)
|
549
690
|
|
550
691
|
expect(transaction.action).to eq(action_name)
|
551
|
-
expect(transaction
|
692
|
+
expect(transaction).to have_action(action_name)
|
552
693
|
end
|
553
694
|
end
|
554
695
|
end
|
@@ -557,13 +698,13 @@ describe Appsignal::Transaction do
|
|
557
698
|
context "when the action is not set" do
|
558
699
|
it "updates the action name on the transaction" do
|
559
700
|
expect(transaction.action).to eq(nil)
|
560
|
-
expect(transaction
|
701
|
+
expect(transaction).to_not have_action
|
561
702
|
|
562
703
|
action_name = "PagesController#show"
|
563
704
|
transaction.set_action_if_nil(action_name)
|
564
705
|
|
565
706
|
expect(transaction.action).to eq(action_name)
|
566
|
-
expect(transaction
|
707
|
+
expect(transaction).to have_action(action_name)
|
567
708
|
end
|
568
709
|
|
569
710
|
context "when the given action is nil" do
|
@@ -573,7 +714,7 @@ describe Appsignal::Transaction do
|
|
573
714
|
transaction.set_action_if_nil(nil)
|
574
715
|
|
575
716
|
expect(transaction.action).to eq(action_name)
|
576
|
-
expect(transaction
|
717
|
+
expect(transaction).to have_action(action_name)
|
577
718
|
end
|
578
719
|
end
|
579
720
|
end
|
@@ -585,7 +726,7 @@ describe Appsignal::Transaction do
|
|
585
726
|
transaction.set_action_if_nil("something else")
|
586
727
|
|
587
728
|
expect(transaction.action).to eq(action_name)
|
588
|
-
expect(transaction
|
729
|
+
expect(transaction).to have_action(action_name)
|
589
730
|
end
|
590
731
|
end
|
591
732
|
end
|
@@ -597,7 +738,7 @@ describe Appsignal::Transaction do
|
|
597
738
|
transaction.set_namespace(namespace)
|
598
739
|
|
599
740
|
expect(transaction.namespace).to eq namespace
|
600
|
-
expect(transaction
|
741
|
+
expect(transaction).to have_namespace(namespace)
|
601
742
|
end
|
602
743
|
end
|
603
744
|
|
@@ -608,7 +749,7 @@ describe Appsignal::Transaction do
|
|
608
749
|
transaction.set_namespace(nil)
|
609
750
|
|
610
751
|
expect(transaction.namespace).to eq(namespace)
|
611
|
-
expect(transaction
|
752
|
+
expect(transaction).to have_namespace(namespace)
|
612
753
|
end
|
613
754
|
end
|
614
755
|
end
|
@@ -620,21 +761,21 @@ describe Appsignal::Transaction do
|
|
620
761
|
:controller => "HomeController",
|
621
762
|
:action => "show"
|
622
763
|
)
|
623
|
-
expect(transaction
|
764
|
+
expect(transaction).to have_action("HomeController#show")
|
624
765
|
end
|
625
766
|
end
|
626
767
|
|
627
768
|
context "for a hash with just action" do
|
628
769
|
it "sets the action" do
|
629
770
|
transaction.set_http_or_background_action(:action => "show")
|
630
|
-
expect(transaction
|
771
|
+
expect(transaction).to have_action("show")
|
631
772
|
end
|
632
773
|
end
|
633
774
|
|
634
775
|
context "for a hash with class and method" do
|
635
776
|
it "sets the action" do
|
636
777
|
transaction.set_http_or_background_action(:class => "Worker", :method => "perform")
|
637
|
-
expect(transaction
|
778
|
+
expect(transaction).to have_action("Worker#perform")
|
638
779
|
end
|
639
780
|
end
|
640
781
|
|
@@ -642,7 +783,7 @@ describe Appsignal::Transaction do
|
|
642
783
|
it "does not overwrite the set action" do
|
643
784
|
transaction.set_action("MyCustomAction#perform")
|
644
785
|
transaction.set_http_or_background_action(:class => "Worker", :method => "perform")
|
645
|
-
expect(transaction
|
786
|
+
expect(transaction).to have_action("MyCustomAction#perform")
|
646
787
|
end
|
647
788
|
end
|
648
789
|
end
|
@@ -665,9 +806,7 @@ describe Appsignal::Transaction do
|
|
665
806
|
|
666
807
|
expect(Appsignal.internal_logger).to receive(:warn).with("Queue start value 10 is too big")
|
667
808
|
|
668
|
-
|
669
|
-
transaction.set_queue_start(10)
|
670
|
-
end.to_not raise_error
|
809
|
+
transaction.set_queue_start(10)
|
671
810
|
end
|
672
811
|
end
|
673
812
|
|
@@ -716,7 +855,7 @@ describe Appsignal::Transaction do
|
|
716
855
|
it "updates the metadata on the transaction" do
|
717
856
|
transaction.set_metadata("request_method", "GET")
|
718
857
|
|
719
|
-
expect(transaction
|
858
|
+
expect(transaction).to include_metadata("request_method" => "GET")
|
720
859
|
end
|
721
860
|
|
722
861
|
context "when filter_metadata includes metadata key" do
|
@@ -727,7 +866,7 @@ describe Appsignal::Transaction do
|
|
727
866
|
transaction.set_metadata(:filter_key, "filtered value")
|
728
867
|
transaction.set_metadata("filter_key", "filtered value")
|
729
868
|
|
730
|
-
expect(transaction
|
869
|
+
expect(transaction).to_not include_metadata("filter_key" => anything)
|
731
870
|
end
|
732
871
|
end
|
733
872
|
|
@@ -735,7 +874,7 @@ describe Appsignal::Transaction do
|
|
735
874
|
it "does not update the metadata on the transaction" do
|
736
875
|
transaction.set_metadata(nil, "GET")
|
737
876
|
|
738
|
-
expect(transaction
|
877
|
+
expect(transaction).to_not include_metadata
|
739
878
|
end
|
740
879
|
end
|
741
880
|
|
@@ -743,7 +882,7 @@ describe Appsignal::Transaction do
|
|
743
882
|
it "does not update the metadata on the transaction" do
|
744
883
|
transaction.set_metadata("request_method", nil)
|
745
884
|
|
746
|
-
expect(transaction
|
885
|
+
expect(transaction).to_not include_metadata
|
747
886
|
end
|
748
887
|
end
|
749
888
|
end
|
@@ -757,12 +896,10 @@ describe Appsignal::Transaction do
|
|
757
896
|
:id => "1"
|
758
897
|
)
|
759
898
|
|
760
|
-
expect(transaction
|
761
|
-
"
|
762
|
-
|
763
|
-
|
764
|
-
"id" => "1"
|
765
|
-
}
|
899
|
+
expect(transaction).to include_params(
|
900
|
+
"action" => "show",
|
901
|
+
"controller" => "blog_posts",
|
902
|
+
"id" => "1"
|
766
903
|
)
|
767
904
|
end
|
768
905
|
|
@@ -785,7 +922,7 @@ describe Appsignal::Transaction do
|
|
785
922
|
end
|
786
923
|
transaction.set_sample_data("params", klass.new => 1)
|
787
924
|
|
788
|
-
expect(transaction
|
925
|
+
expect(transaction).to_not include_params
|
789
926
|
expect(log_contents(log)).to contains_log :error,
|
790
927
|
"Error generating data (RuntimeError: foo) for"
|
791
928
|
end
|
@@ -800,29 +937,39 @@ describe Appsignal::Transaction do
|
|
800
937
|
transaction.add_breadcrumb "category", "action", "message", "key" => "value"
|
801
938
|
transaction.sample_data
|
802
939
|
|
803
|
-
|
804
|
-
expect(sample_data["environment"]).to include(
|
940
|
+
expect(transaction).to include_environment(
|
805
941
|
"REQUEST_METHOD" => "GET",
|
806
942
|
"SERVER_NAME" => "example.org",
|
807
943
|
"SERVER_PORT" => "80",
|
808
944
|
"PATH_INFO" => "/blog"
|
809
945
|
)
|
810
|
-
expect(
|
811
|
-
expect(
|
946
|
+
expect(transaction).to include_session_data("session" => "value")
|
947
|
+
expect(transaction).to include_params(
|
812
948
|
"controller" => "blog_posts",
|
813
949
|
"action" => "show",
|
814
950
|
"id" => "1"
|
815
951
|
)
|
816
|
-
expect(
|
817
|
-
expect(
|
818
|
-
expect(
|
819
|
-
"action"
|
820
|
-
"category"
|
821
|
-
"message"
|
822
|
-
|
823
|
-
|
952
|
+
expect(transaction).to include_sample_metadata("key" => "value")
|
953
|
+
expect(transaction).to include_tags("tag" => "value")
|
954
|
+
expect(transaction).to include_breadcrumb(
|
955
|
+
"action",
|
956
|
+
"category",
|
957
|
+
"message",
|
958
|
+
{ "key" => "value" },
|
959
|
+
kind_of(Integer)
|
824
960
|
)
|
825
961
|
end
|
962
|
+
|
963
|
+
context "when params is a callable object" do
|
964
|
+
it "calls the params object and sets the return value as parametesr" do
|
965
|
+
transaction.set_params { { "param1" => "value1" } }
|
966
|
+
|
967
|
+
transaction.sample_data
|
968
|
+
expect(transaction).to include_params(
|
969
|
+
"param1" => "value1"
|
970
|
+
)
|
971
|
+
end
|
972
|
+
end
|
826
973
|
end
|
827
974
|
|
828
975
|
describe "#set_error" do
|
@@ -972,7 +1119,7 @@ describe Appsignal::Transaction do
|
|
972
1119
|
end
|
973
1120
|
|
974
1121
|
it "should not raise an error" do
|
975
|
-
|
1122
|
+
transaction.set_error(error)
|
976
1123
|
end
|
977
1124
|
|
978
1125
|
it "should set an error in the extension" do
|
@@ -1613,22 +1760,20 @@ describe Appsignal::Transaction do
|
|
1613
1760
|
subject { Appsignal::Transaction::NilTransaction.new }
|
1614
1761
|
|
1615
1762
|
it "should have method stubs" do
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
subject.set_error("a")
|
1631
|
-
end.to_not raise_error
|
1763
|
+
subject.complete
|
1764
|
+
subject.pause!
|
1765
|
+
subject.resume!
|
1766
|
+
subject.paused?
|
1767
|
+
subject.store(:key)
|
1768
|
+
subject.set_tags(:tag => 1)
|
1769
|
+
subject.set_action("action")
|
1770
|
+
subject.set_http_or_background_action
|
1771
|
+
subject.set_queue_start(1)
|
1772
|
+
subject.set_http_or_background_queue_start
|
1773
|
+
subject.set_metadata("key", "value")
|
1774
|
+
subject.set_sample_data("key", "data")
|
1775
|
+
subject.sample_data
|
1776
|
+
subject.set_error("a")
|
1632
1777
|
end
|
1633
1778
|
end
|
1634
1779
|
end
|