appsignal 3.10.0-java → 3.11.0-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/.rubocop.yml +1 -1
- data/CHANGELOG.md +88 -0
- data/Gemfile +1 -0
- data/benchmark.rake +99 -42
- data/lib/appsignal/cli/demo.rb +0 -1
- data/lib/appsignal/config.rb +54 -98
- data/lib/appsignal/demo.rb +15 -20
- data/lib/appsignal/event_formatter/rom/sql_formatter.rb +1 -0
- data/lib/appsignal/event_formatter.rb +3 -2
- data/lib/appsignal/helpers/instrumentation.rb +331 -19
- data/lib/appsignal/hooks/action_cable.rb +21 -16
- data/lib/appsignal/hooks/active_job.rb +14 -8
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/shoryuken.rb +3 -63
- data/lib/appsignal/integrations/action_cable.rb +5 -7
- data/lib/appsignal/integrations/active_support_notifications.rb +1 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +36 -35
- data/lib/appsignal/integrations/data_mapper.rb +1 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +27 -33
- data/lib/appsignal/integrations/dry_monitor.rb +1 -0
- data/lib/appsignal/integrations/excon.rb +1 -0
- data/lib/appsignal/integrations/http.rb +1 -0
- data/lib/appsignal/integrations/net_http.rb +1 -0
- data/lib/appsignal/integrations/object.rb +6 -0
- data/lib/appsignal/integrations/que.rb +13 -20
- data/lib/appsignal/integrations/railtie.rb +1 -1
- data/lib/appsignal/integrations/rake.rb +1 -5
- data/lib/appsignal/integrations/redis.rb +1 -0
- data/lib/appsignal/integrations/redis_client.rb +1 -0
- data/lib/appsignal/integrations/resque.rb +2 -5
- data/lib/appsignal/integrations/shoryuken.rb +75 -0
- data/lib/appsignal/integrations/sidekiq.rb +7 -15
- data/lib/appsignal/integrations/unicorn.rb +1 -0
- data/lib/appsignal/integrations/webmachine.rb +2 -5
- data/lib/appsignal/logger.rb +7 -3
- data/lib/appsignal/probes/helpers.rb +1 -0
- data/lib/appsignal/probes/mri.rb +1 -0
- data/lib/appsignal/probes/sidekiq.rb +1 -0
- data/lib/appsignal/probes.rb +3 -0
- data/lib/appsignal/rack/abstract_middleware.rb +18 -12
- data/lib/appsignal/rack/event_handler.rb +39 -8
- data/lib/appsignal/rack/generic_instrumentation.rb +1 -0
- data/lib/appsignal/rack/grape_middleware.rb +2 -1
- data/lib/appsignal/rack/streaming_listener.rb +1 -0
- data/lib/appsignal/rack.rb +29 -0
- data/lib/appsignal/span.rb +1 -0
- data/lib/appsignal/transaction.rb +308 -101
- data/lib/appsignal/utils/data.rb +0 -1
- data/lib/appsignal/utils/hash_sanitizer.rb +0 -1
- data/lib/appsignal/utils/integration_logger.rb +0 -13
- data/lib/appsignal/utils/integration_memory_logger.rb +0 -13
- data/lib/appsignal/utils/json.rb +0 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +0 -1
- data/lib/appsignal/utils/stdout_and_logger_message.rb +0 -1
- data/lib/appsignal/utils.rb +6 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +6 -5
- data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +138 -43
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +43 -74
- data/spec/lib/appsignal/hooks/activejob_spec.rb +9 -0
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +2 -443
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -171
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +459 -0
- data/spec/lib/appsignal/integrations/que_spec.rb +3 -4
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +167 -0
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -4
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +13 -1
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +48 -3
- data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -10
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +4 -2
- data/spec/lib/appsignal/rack_spec.rb +63 -0
- data/spec/lib/appsignal/transaction_spec.rb +1634 -1071
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +12 -16
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -10
- data/spec/lib/appsignal_spec.rb +323 -10
- data/spec/support/helpers/transaction_helpers.rb +44 -20
- data/spec/support/matchers/transaction.rb +15 -1
- data/spec/support/testing.rb +1 -1
- metadata +6 -2
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
describe Appsignal::Utils::IntegrationLogger do
|
|
2
|
-
let(:
|
|
2
|
+
let(:log_stream) { std_stream }
|
|
3
|
+
let(:logs) { log_contents(log_stream) }
|
|
3
4
|
let(:logger) do
|
|
4
|
-
Appsignal::Utils::IntegrationLogger.new(
|
|
5
|
+
Appsignal::Utils::IntegrationLogger.new(log_stream).tap do |l|
|
|
5
6
|
l.formatter = logger_formatter
|
|
6
7
|
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
it "logs messages" do
|
|
11
|
+
logger.debug("debug message")
|
|
12
|
+
logger.info("info message")
|
|
13
|
+
logger.warn("warning message")
|
|
14
|
+
logger.error("error message")
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
logs = log_contents(log)
|
|
21
|
-
expect(logs.scan(/#{Regexp.escape(log_line(:WARN, message))}/).count).to eql(1)
|
|
22
|
-
expect(logs.scan(/#{Regexp.escape(log_line(:DEBUG, message))}/).count).to eql(2)
|
|
23
|
-
end
|
|
16
|
+
expect(logs).to contains_log(:debug, "debug message")
|
|
17
|
+
expect(logs).to contains_log(:info, "info message")
|
|
18
|
+
expect(logs).to contains_log(:warn, "warning message")
|
|
19
|
+
expect(logs).to contains_log(:error, "error message")
|
|
24
20
|
end
|
|
25
21
|
end
|
|
@@ -68,16 +68,6 @@ describe Appsignal::Utils::IntegrationLogger do
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
describe "#warn_once_then_debug" do
|
|
72
|
-
it "only warns once, then uses debug" do
|
|
73
|
-
message = "This is a log line"
|
|
74
|
-
3.times { logger.warn_once_then_debug(:key, message) }
|
|
75
|
-
|
|
76
|
-
expect(logger.messages[:WARN]).to eq([message])
|
|
77
|
-
expect(logger.messages[:DEBUG]).to eq([message, message])
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
71
|
describe "#error" do
|
|
82
72
|
it "adds a log message with the error severity" do
|
|
83
73
|
logger.error("error message")
|
data/spec/lib/appsignal_spec.rb
CHANGED
|
@@ -358,7 +358,178 @@ describe Appsignal do
|
|
|
358
358
|
before { start_agent }
|
|
359
359
|
around { |example| keep_transactions { example.run } }
|
|
360
360
|
|
|
361
|
+
describe ".monitor" do
|
|
362
|
+
it "creates a transaction" do
|
|
363
|
+
expect do
|
|
364
|
+
Appsignal.monitor(:action => "MyAction")
|
|
365
|
+
end.to(change { created_transactions.count }.by(1))
|
|
366
|
+
|
|
367
|
+
transaction = last_transaction
|
|
368
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
|
369
|
+
expect(transaction).to have_action("MyAction")
|
|
370
|
+
expect(transaction).to_not have_error
|
|
371
|
+
expect(transaction).to_not include_events
|
|
372
|
+
expect(transaction).to_not have_queue_start
|
|
373
|
+
expect(transaction).to be_completed
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
it "returns the block's return value" do
|
|
377
|
+
expect(Appsignal.monitor(:action => nil) { :return_value }).to eq(:return_value)
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
it "sets a custom namespace via the namespace argument" do
|
|
381
|
+
Appsignal.monitor(:namespace => "custom", :action => nil)
|
|
382
|
+
|
|
383
|
+
expect(last_transaction).to have_namespace("custom")
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
it "doesn't overwrite custom namespace set in the block" do
|
|
387
|
+
Appsignal.monitor(:namespace => "custom", :action => nil) do
|
|
388
|
+
Appsignal.set_namespace("more custom")
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
expect(last_transaction).to have_namespace("more custom")
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
it "sets the action via the action argument using a string" do
|
|
395
|
+
Appsignal.monitor(:action => "custom")
|
|
396
|
+
|
|
397
|
+
expect(last_transaction).to have_action("custom")
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
it "sets the action via the action argument using a symbol" do
|
|
401
|
+
Appsignal.monitor(:action => :custom)
|
|
402
|
+
|
|
403
|
+
expect(last_transaction).to have_action("custom")
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
it "doesn't overwrite custom action set in the block" do
|
|
407
|
+
Appsignal.monitor(:action => "custom") do
|
|
408
|
+
Appsignal.set_action("more custom")
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
expect(last_transaction).to have_action("more custom")
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
it "doesn't set the action when value is nil" do
|
|
415
|
+
Appsignal.monitor(:action => nil)
|
|
416
|
+
|
|
417
|
+
expect(last_transaction).to_not have_action
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it "doesn't set the action when value is :set_later" do
|
|
421
|
+
Appsignal.monitor(:action => :set_later)
|
|
422
|
+
|
|
423
|
+
expect(last_transaction).to_not have_action
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
it "reports exceptions that occur in the block" do
|
|
427
|
+
expect do
|
|
428
|
+
Appsignal.monitor :action => nil do
|
|
429
|
+
raise ExampleException, "error message"
|
|
430
|
+
end
|
|
431
|
+
end.to raise_error(ExampleException, "error message")
|
|
432
|
+
|
|
433
|
+
expect(last_transaction).to have_error("ExampleException", "error message")
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
context "with already active transction" do
|
|
437
|
+
let(:err_stream) { std_stream }
|
|
438
|
+
let(:stderr) { err_stream.read }
|
|
439
|
+
let(:transaction) { http_request_transaction }
|
|
440
|
+
before do
|
|
441
|
+
set_current_transaction(transaction)
|
|
442
|
+
transaction.set_action("My action")
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
it "doesn't create a new transaction" do
|
|
446
|
+
logs = nil
|
|
447
|
+
expect do
|
|
448
|
+
logs =
|
|
449
|
+
capture_logs do
|
|
450
|
+
capture_std_streams(std_stream, err_stream) do
|
|
451
|
+
Appsignal.monitor(:action => nil)
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
end.to_not(change { created_transactions.count })
|
|
455
|
+
|
|
456
|
+
warning = "An active transaction around this 'Appsignal.monitor' call."
|
|
457
|
+
expect(logs).to contains_log(:warn, warning)
|
|
458
|
+
expect(stderr).to include("appsignal WARNING: #{warning}")
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
it "does not overwrite the parent transaction's namespace" do
|
|
462
|
+
silence { Appsignal.monitor(:namespace => "custom", :action => nil) }
|
|
463
|
+
|
|
464
|
+
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
it "does not overwrite the parent transaction's action" do
|
|
468
|
+
silence { Appsignal.monitor(:action => "custom") }
|
|
469
|
+
|
|
470
|
+
expect(transaction).to have_action("My action")
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
it "doesn't complete the parent transaction" do
|
|
474
|
+
silence { Appsignal.monitor(:action => nil) }
|
|
475
|
+
|
|
476
|
+
expect(transaction).to_not be_completed
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
describe ".monitor_and_stop" do
|
|
482
|
+
it "calls Appsignal.stop after the block" do
|
|
483
|
+
allow(Appsignal).to receive(:stop)
|
|
484
|
+
Appsignal.monitor_and_stop(:namespace => "custom", :action => "My Action")
|
|
485
|
+
|
|
486
|
+
transaction = last_transaction
|
|
487
|
+
expect(transaction).to have_namespace("custom")
|
|
488
|
+
expect(transaction).to have_action("My Action")
|
|
489
|
+
expect(transaction).to be_completed
|
|
490
|
+
|
|
491
|
+
expect(Appsignal).to have_received(:stop).with("monitor_and_stop")
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
361
495
|
describe ".monitor_transaction" do
|
|
496
|
+
it "prints a deprecation warning" do
|
|
497
|
+
err_stream = std_stream
|
|
498
|
+
capture_std_streams(std_stream, err_stream) do
|
|
499
|
+
Appsignal.monitor_transaction(
|
|
500
|
+
"perform_job.something",
|
|
501
|
+
:class => "BackgroundJob",
|
|
502
|
+
:method => "perform"
|
|
503
|
+
) do
|
|
504
|
+
:return_value
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
expect(err_stream.read).to include(
|
|
509
|
+
"appsignal WARNING: The `Appsignal.monitor_transaction` helper is deprecated."
|
|
510
|
+
)
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
it "logs a deprecation warning" do
|
|
514
|
+
logs =
|
|
515
|
+
capture_logs do
|
|
516
|
+
silence do
|
|
517
|
+
Appsignal.monitor_transaction(
|
|
518
|
+
"perform_job.something",
|
|
519
|
+
:class => "BackgroundJob",
|
|
520
|
+
:method => "perform"
|
|
521
|
+
) do
|
|
522
|
+
:return_value
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
expect(logs).to contains_log(
|
|
528
|
+
:warn,
|
|
529
|
+
"The `Appsignal.monitor_transaction` helper is deprecated."
|
|
530
|
+
)
|
|
531
|
+
end
|
|
532
|
+
|
|
362
533
|
context "with a successful call" do
|
|
363
534
|
it "instruments and completes for a background job" do
|
|
364
535
|
return_value = nil
|
|
@@ -368,7 +539,8 @@ describe Appsignal do
|
|
|
368
539
|
"perform_job.something",
|
|
369
540
|
{
|
|
370
541
|
:class => "BackgroundJob",
|
|
371
|
-
:method => "perform"
|
|
542
|
+
:method => "perform",
|
|
543
|
+
:queue_start => fixed_time.to_i
|
|
372
544
|
}
|
|
373
545
|
) do
|
|
374
546
|
:return_value
|
|
@@ -380,6 +552,7 @@ describe Appsignal do
|
|
|
380
552
|
expect(transaction).to have_namespace(Appsignal::Transaction::BACKGROUND_JOB)
|
|
381
553
|
expect(transaction).to have_action("BackgroundJob#perform")
|
|
382
554
|
expect(transaction).to include_event("name" => "perform_job.something")
|
|
555
|
+
expect(transaction).to have_queue_start(1_389_783_600_000)
|
|
383
556
|
expect(transaction).to be_completed
|
|
384
557
|
end
|
|
385
558
|
|
|
@@ -391,7 +564,8 @@ describe Appsignal do
|
|
|
391
564
|
"process_action.something",
|
|
392
565
|
{
|
|
393
566
|
:controller => "BlogPostsController",
|
|
394
|
-
:action => "show"
|
|
567
|
+
:action => "show",
|
|
568
|
+
"HTTP_X_REQUEST_START" => "t=#{fixed_time.to_i * 1000}"
|
|
395
569
|
}
|
|
396
570
|
) do
|
|
397
571
|
:return_value
|
|
@@ -403,6 +577,7 @@ describe Appsignal do
|
|
|
403
577
|
expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
|
|
404
578
|
expect(transaction).to have_action("BlogPostsController#show")
|
|
405
579
|
expect(transaction).to include_event("name" => "process_action.something")
|
|
580
|
+
expect(transaction).to have_queue_start(1_389_783_600_000)
|
|
406
581
|
expect(transaction).to be_completed
|
|
407
582
|
end
|
|
408
583
|
end
|
|
@@ -444,6 +619,43 @@ describe Appsignal do
|
|
|
444
619
|
end
|
|
445
620
|
|
|
446
621
|
describe ".monitor_single_transaction" do
|
|
622
|
+
it "prints a deprecation warning" do
|
|
623
|
+
err_stream = std_stream
|
|
624
|
+
capture_std_streams(std_stream, err_stream) do
|
|
625
|
+
Appsignal.monitor_single_transaction(
|
|
626
|
+
"perform_job.something",
|
|
627
|
+
:class => "BackgroundJob",
|
|
628
|
+
:method => "perform"
|
|
629
|
+
) do
|
|
630
|
+
:return_value
|
|
631
|
+
end
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
expect(err_stream.read).to include(
|
|
635
|
+
"appsignal WARNING: The `Appsignal.monitor_single_transaction` helper is deprecated."
|
|
636
|
+
)
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
it "logs a deprecation warning" do
|
|
640
|
+
logs =
|
|
641
|
+
capture_logs do
|
|
642
|
+
silence do
|
|
643
|
+
Appsignal.monitor_single_transaction(
|
|
644
|
+
"perform_job.something",
|
|
645
|
+
:class => "BackgroundJob",
|
|
646
|
+
:method => "perform"
|
|
647
|
+
) do
|
|
648
|
+
:return_value
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
expect(logs).to contains_log(
|
|
654
|
+
:warn,
|
|
655
|
+
"The `Appsignal.monitor_single_transaction` helper is deprecated."
|
|
656
|
+
)
|
|
657
|
+
end
|
|
658
|
+
|
|
447
659
|
context "with a successful call" do
|
|
448
660
|
it "calls monitor_transaction and Appsignal.stop" do
|
|
449
661
|
expect(Appsignal).to receive(:stop)
|
|
@@ -521,9 +733,7 @@ describe Appsignal do
|
|
|
521
733
|
end
|
|
522
734
|
|
|
523
735
|
describe ".set_params" do
|
|
524
|
-
before
|
|
525
|
-
start_agent
|
|
526
|
-
end
|
|
736
|
+
before { start_agent }
|
|
527
737
|
|
|
528
738
|
context "with transaction" do
|
|
529
739
|
let(:transaction) { http_request_transaction }
|
|
@@ -561,6 +771,84 @@ describe Appsignal do
|
|
|
561
771
|
end
|
|
562
772
|
end
|
|
563
773
|
|
|
774
|
+
describe ".set_session_data" do
|
|
775
|
+
before { start_agent }
|
|
776
|
+
|
|
777
|
+
context "with transaction" do
|
|
778
|
+
let(:transaction) { http_request_transaction }
|
|
779
|
+
before { set_current_transaction(transaction) }
|
|
780
|
+
|
|
781
|
+
it "sets session data on the transaction" do
|
|
782
|
+
Appsignal.set_session_data("data" => "value1")
|
|
783
|
+
|
|
784
|
+
transaction._sample
|
|
785
|
+
expect(transaction).to include_session_data("data" => "value1")
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
it "overwrites the session data if called multiple times" do
|
|
789
|
+
Appsignal.set_session_data("data" => "value1")
|
|
790
|
+
Appsignal.set_session_data("data" => "value2")
|
|
791
|
+
|
|
792
|
+
transaction._sample
|
|
793
|
+
expect(transaction).to include_session_data("data" => "value2")
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
it "sets session data with a block on the transaction" do
|
|
797
|
+
Appsignal.set_session_data { { "data" => "value1" } }
|
|
798
|
+
|
|
799
|
+
transaction._sample
|
|
800
|
+
expect(transaction).to include_session_data("data" => "value1")
|
|
801
|
+
end
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
context "without transaction" do
|
|
805
|
+
it "does not set session data on the transaction" do
|
|
806
|
+
Appsignal.set_session_data("a" => "b")
|
|
807
|
+
|
|
808
|
+
expect_any_instance_of(Appsignal::Transaction).to_not receive(:set_session_data)
|
|
809
|
+
end
|
|
810
|
+
end
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
describe ".set_headers" do
|
|
814
|
+
before { start_agent }
|
|
815
|
+
|
|
816
|
+
context "with transaction" do
|
|
817
|
+
let(:transaction) { http_request_transaction }
|
|
818
|
+
before { set_current_transaction(transaction) }
|
|
819
|
+
|
|
820
|
+
it "sets request headers on the transaction" do
|
|
821
|
+
Appsignal.set_headers("PATH_INFO" => "/some-path")
|
|
822
|
+
|
|
823
|
+
transaction._sample
|
|
824
|
+
expect(transaction).to include_environment("PATH_INFO" => "/some-path")
|
|
825
|
+
end
|
|
826
|
+
|
|
827
|
+
it "overwrites the request headers if called multiple times" do
|
|
828
|
+
Appsignal.set_headers("PATH_INFO" => "/some-path1")
|
|
829
|
+
Appsignal.set_headers("PATH_INFO" => "/some-path2")
|
|
830
|
+
|
|
831
|
+
transaction._sample
|
|
832
|
+
expect(transaction).to include_environment("PATH_INFO" => "/some-path2")
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
it "sets request headers with a block on the transaction" do
|
|
836
|
+
Appsignal.set_headers { { "PATH_INFO" => "/some-path" } }
|
|
837
|
+
|
|
838
|
+
transaction._sample
|
|
839
|
+
expect(transaction).to include_environment("PATH_INFO" => "/some-path")
|
|
840
|
+
end
|
|
841
|
+
end
|
|
842
|
+
|
|
843
|
+
context "without transaction" do
|
|
844
|
+
it "does not set request headers on the transaction" do
|
|
845
|
+
Appsignal.set_headers("PATH_INFO" => "/some-path")
|
|
846
|
+
|
|
847
|
+
expect_any_instance_of(Appsignal::Transaction).to_not receive(:set_headers)
|
|
848
|
+
end
|
|
849
|
+
end
|
|
850
|
+
end
|
|
851
|
+
|
|
564
852
|
describe ".set_custom_data" do
|
|
565
853
|
before { start_agent }
|
|
566
854
|
|
|
@@ -1269,7 +1557,7 @@ describe Appsignal do
|
|
|
1269
1557
|
end
|
|
1270
1558
|
end
|
|
1271
1559
|
|
|
1272
|
-
describe ".
|
|
1560
|
+
describe ".ignore_instrumentation_events" do
|
|
1273
1561
|
around { |example| keep_transactions { example.run } }
|
|
1274
1562
|
let(:transaction) { http_request_transaction }
|
|
1275
1563
|
|
|
@@ -1281,20 +1569,44 @@ describe Appsignal do
|
|
|
1281
1569
|
expect(transaction).to receive(:resume!).and_call_original
|
|
1282
1570
|
|
|
1283
1571
|
Appsignal.instrument("register.this.event") { :do_nothing }
|
|
1284
|
-
Appsignal.
|
|
1572
|
+
Appsignal.ignore_instrumentation_events do
|
|
1285
1573
|
Appsignal.instrument("dont.register.this.event") { :do_nothing }
|
|
1286
1574
|
end
|
|
1287
1575
|
|
|
1288
1576
|
expect(transaction).to include_event("name" => "register.this.event")
|
|
1289
1577
|
expect(transaction).to_not include_event("name" => "dont.register.this.event")
|
|
1290
1578
|
end
|
|
1579
|
+
|
|
1580
|
+
it "has a without_instrumentation alias that prints a deprecation warning" do
|
|
1581
|
+
Appsignal.instrument("register.this.event") { :do_nothing }
|
|
1582
|
+
err_stream = std_stream
|
|
1583
|
+
logs =
|
|
1584
|
+
capture_logs do
|
|
1585
|
+
capture_std_streams(std_stream, err_stream) do
|
|
1586
|
+
Appsignal.without_instrumentation do
|
|
1587
|
+
Appsignal.instrument("dont.register.this.event") { :do_nothing }
|
|
1588
|
+
end
|
|
1589
|
+
end
|
|
1590
|
+
end
|
|
1591
|
+
|
|
1592
|
+
expect(transaction).to include_event("name" => "register.this.event")
|
|
1593
|
+
expect(transaction).to_not include_event("name" => "dont.register.this.event")
|
|
1594
|
+
|
|
1595
|
+
expect(logs).to contains_log(
|
|
1596
|
+
:warn,
|
|
1597
|
+
"The `Appsignal.without_instrumentation` helper is deprecated."
|
|
1598
|
+
)
|
|
1599
|
+
expect(err_stream.read).to include(
|
|
1600
|
+
"appsignal WARNING: The `Appsignal.without_instrumentation` helper is deprecated."
|
|
1601
|
+
)
|
|
1602
|
+
end
|
|
1291
1603
|
end
|
|
1292
1604
|
|
|
1293
1605
|
context "without current transaction" do
|
|
1294
1606
|
let(:transaction) { nil }
|
|
1295
1607
|
|
|
1296
1608
|
it "does not crash" do
|
|
1297
|
-
Appsignal.
|
|
1609
|
+
Appsignal.ignore_instrumentation_events { :do_nothing }
|
|
1298
1610
|
end
|
|
1299
1611
|
end
|
|
1300
1612
|
end
|
|
@@ -1312,8 +1624,9 @@ describe Appsignal do
|
|
|
1312
1624
|
Appsignal.start_logger
|
|
1313
1625
|
end
|
|
1314
1626
|
end
|
|
1315
|
-
expect(stderr)
|
|
1316
|
-
|
|
1627
|
+
expect(stderr)
|
|
1628
|
+
.to include("appsignal WARNING: Calling 'Appsignal.start_logger' is deprecated.")
|
|
1629
|
+
expect(log).to contains_log(:warn, "Calling 'Appsignal.start_logger' is deprecated.")
|
|
1317
1630
|
end
|
|
1318
1631
|
end
|
|
1319
1632
|
|
|
@@ -7,26 +7,50 @@ module TransactionHelpers
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
Appsignal::Transaction
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
def default_namespace
|
|
11
|
+
Appsignal::Transaction::HTTP_REQUEST
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_transaction(namespace = default_namespace)
|
|
15
|
+
Appsignal::Transaction.create(namespace)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def new_transaction(namespace = default_namespace)
|
|
19
|
+
Appsignal::Transaction.new(SecureRandom.uuid, namespace)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def legacy_create_transaction(
|
|
23
|
+
id: "mock_transaction_id",
|
|
24
|
+
namespace: "mock_namespace",
|
|
25
|
+
request: legacy_request,
|
|
26
|
+
options: {}
|
|
27
|
+
)
|
|
28
|
+
Appsignal::Transaction.create(id, namespace, request, options)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def legacy_new_transaction(
|
|
32
|
+
id: "mock_transaction_id",
|
|
33
|
+
namespace: "mock_namespace",
|
|
34
|
+
request: legacy_request,
|
|
35
|
+
options: {}
|
|
36
|
+
)
|
|
37
|
+
Appsignal::Transaction.new(id, namespace, request, options)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def legacy_request(env = {})
|
|
41
|
+
Appsignal::Transaction::InternalGenericRequest.new(env)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def rack_request(env)
|
|
45
|
+
Rack::Request.new(env)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def background_job_transaction
|
|
49
|
+
new_transaction(Appsignal::Transaction::BACKGROUND_JOB)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def http_request_transaction
|
|
53
|
+
new_transaction(Appsignal::Transaction::HTTP_REQUEST)
|
|
30
54
|
end
|
|
31
55
|
|
|
32
56
|
# Returns the all {Appsignal::Transaction} objects created during this test
|
|
@@ -180,6 +180,20 @@ RSpec::Matchers.alias_matcher :include_breadcrumbs, :include_breadcrumb
|
|
|
180
180
|
|
|
181
181
|
RSpec::Matchers.define :have_queue_start do |queue_start_time|
|
|
182
182
|
match(:notify_expectation_failures => true) do |transaction|
|
|
183
|
-
|
|
183
|
+
actual_start = transaction.ext.queue_start
|
|
184
|
+
if queue_start_time
|
|
185
|
+
expect(actual_start).to eq(queue_start_time)
|
|
186
|
+
else
|
|
187
|
+
expect(actual_start).to_not be_nil
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
|
192
|
+
actual_start = transaction.ext.queue_start
|
|
193
|
+
if queue_start_time
|
|
194
|
+
expect(actual_start).to_not eq(queue_start_time)
|
|
195
|
+
else
|
|
196
|
+
expect(actual_start).to be_nil
|
|
197
|
+
end
|
|
184
198
|
end
|
|
185
199
|
end
|
data/spec/support/testing.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: appsignal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.11.0
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Beekman
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2024-07-
|
|
13
|
+
date: 2024-07-15 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rack
|
|
@@ -275,6 +275,7 @@ files:
|
|
|
275
275
|
- lib/appsignal/integrations/redis.rb
|
|
276
276
|
- lib/appsignal/integrations/redis_client.rb
|
|
277
277
|
- lib/appsignal/integrations/resque.rb
|
|
278
|
+
- lib/appsignal/integrations/shoryuken.rb
|
|
278
279
|
- lib/appsignal/integrations/sidekiq.rb
|
|
279
280
|
- lib/appsignal/integrations/sinatra.rb
|
|
280
281
|
- lib/appsignal/integrations/unicorn.rb
|
|
@@ -376,6 +377,7 @@ files:
|
|
|
376
377
|
- spec/lib/appsignal/hooks/webmachine_spec.rb
|
|
377
378
|
- spec/lib/appsignal/hooks_spec.rb
|
|
378
379
|
- spec/lib/appsignal/integrations/data_mapper_spec.rb
|
|
380
|
+
- spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb
|
|
379
381
|
- spec/lib/appsignal/integrations/hanami_spec.rb
|
|
380
382
|
- spec/lib/appsignal/integrations/http_spec.rb
|
|
381
383
|
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
|
@@ -384,6 +386,7 @@ files:
|
|
|
384
386
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
|
385
387
|
- spec/lib/appsignal/integrations/que_spec.rb
|
|
386
388
|
- spec/lib/appsignal/integrations/railtie_spec.rb
|
|
389
|
+
- spec/lib/appsignal/integrations/shoryuken_spec.rb
|
|
387
390
|
- spec/lib/appsignal/integrations/sidekiq_spec.rb
|
|
388
391
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
|
389
392
|
- spec/lib/appsignal/integrations/webmachine_spec.rb
|
|
@@ -403,6 +406,7 @@ files:
|
|
|
403
406
|
- spec/lib/appsignal/rack/rails_instrumentation_spec.rb
|
|
404
407
|
- spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
|
|
405
408
|
- spec/lib/appsignal/rack/streaming_listener_spec.rb
|
|
409
|
+
- spec/lib/appsignal/rack_spec.rb
|
|
406
410
|
- spec/lib/appsignal/span_spec.rb
|
|
407
411
|
- spec/lib/appsignal/system_spec.rb
|
|
408
412
|
- spec/lib/appsignal/transaction_spec.rb
|